educative.io

Not able to pass all the test cases for the same question on leetcode

This solution is not passing all the test cases on Leetcode.

input: [1,0,1,0,1,0,0,1,0,0,1,1,1,0,0,1,0,0,439,0,439,0,439,0,439,439,0,0,0,0,366,366,692,692,366,366,692,692,366,692,692,366,366,692,366,692,692,692,366,692,313,692,313,692,692,313,692,313,692,692,313,692,313,313,313,145,313,145,145,420,145,420,145,145,145,145,420,145,145,420,145,145,424,145,145,424,145,464,464,464,145,145,464,145,464,145,145,464,145,960,145,145,960,960,141,141,141,960,960,903,960,395,395,960,395,395,960,960,395,960,395,395,960,960,960,395,395,395,395,395,395,395,960,395,971,971,395,971,386,386,971,386,386,665,386,665,665,386,386,665,665,665,386,386,665,665,665,386,386,665,386,665,386,609,609,386,386,609,386,609,386,386,386,386,386,386,386,609,386,386,386,609,386,386,609,386,386,386,386,386,386,609,609,386,386,609,386,44,386,44,386,44,307,923,923,307,307,982,307,307,461,307,461,461,461,461,461,307,307,461,484,484,484,484,484,484,461,461,461,461,461,505,461,505,505,461,461,505,461,505,461,505,505,505,505,505,505,461,461,505,275,275,275,275,899,275,275,899,968,968,968,899,420,420,404,420,404,420,404,236,404,404,236,404,236,404,236,236,236,404,236,236,236,236,236,236,215,215,236,215,215,236,215,215,236,236,215,215,215,215,236,236,236,236,236,236,215,215,215,215,215,236,215,236,215,236,215,236,215,236,236,492,236,730,730,236,730,236,338,849,338,849,849,338,849,338,849,338,338,338,849,338,338,849,849,338,338,849,849,849,849,338,849,849,849,849,338,338,338,338,759,427,759,759,427,759,759,759,759,759,759,427,759,759,759,664,48,664,664,48,664,48,490,490,490,490,490,48,48,490,490,48,490,48,48,490,490,48,48,490,48,863,72,72,863,863,863,863,72,863,736,863,55,55,863,55,55,55,55,863,863,863,863,863,863,55,863,55,55,55,55,55,863,55,55,346,55,55,55,55,55,55,55,346,346,346,346,55,55,55,55,346,55,55,346,346,346,346,346,55,173,55,55,55,55,173,55,173,173,55,173,95,173,95,173,173,95,95,95,173,173,35,35,173,173,173,173,101,101,101,101,173,101,998,998,101,998,101,998,998,101,101,998,101,101,998,838,838,998,892,287,287,892,892,287,892,892,287,84,287,84,287,719,719,287,719,202,202,719,719,719,202,719,202,719,202,719,202,202,202,202,719,202,719,719,202,719,719,719,719,202,719,202,947,852,947,852,852,852,947,133,947,133,133,682,133,682,682,682,133,133,133,682,682,133,682,682,682,133,133,682,682,133,133,682,682,133,682,682,306,682,682,306,682,992,682,710,710,710,682,682,682,682,710,682,682,682,710,682,682,682,710,710,710,682,682,682,682,682,710,682,710,710,710,682,710,710,682,682,710,710,710,682,710,682,335,682,167,167,167,682,851,851,851,851,682,851,851,682,851,851,851,693,693,693,693,693,851,851,693,693,693,851,693,851,851,693,851,851,922,851,851,851,922,851,922,922,851,922,851,851,922,851,922,922,922,922,922,851,851,539,539,851,539,539,539,539,539,851,539,539,539,851,851,539,539,851,539,851,539,851,539,539,539,851,508,851,851,508,508,851,851,979,979,851,851,851,979,979,979,851,979,851,979,979,979,851,588,588,588,588,851,588,851,588,588,588,588,588,851,588,588,588,851,930,930,930,851,930,930,851,851,851,851,851,930,930,851,930,930,930,930,851,851,851,851,851,851,851,851,718,718,851,769,851,769,851,851,851,851,851,851,769,769,769,851,447,447,447,447,851,851,909,851,851,880,851,851,880,851,851,851,880,880,880,851,880,931,931,931,880,880,931,931,684,684,931,684,931,931,931,242,931,242,242,242,931,242,931,931,931,931,242,931,931,728,931,728,931,848,931,848,188,188,188,188,848,188,188,188,188,848,188,188,848,848,848,848,848,188,848,848,759,848,759,759,848,759,848,931,848,848,931,930,931,930,930,930,930,930,750,750,930,930,930,750,750,930,930,930,750,750,750,930,750,930,930,750,750,750,930,930,750,750,750,930,750,930,930,930,329,930,930,329,784,784,329,329,784,784,329,784,784,329,329,784,329,329,329,784,329,784,329,784,784,784,329,329,784,784,329,784,329,329,784,784,329,575,575,575,575,329,575,329,329,329,575,329,329,260,329,329,329,329,46,329,189,189,618,618,618,618,618,189,189,438,262,363,363,262,262,262,363,262,363,262,262,262,262,363]

Output: 43
Expected: 41

Type your question above this line.

Course: https://www.educative.io/collection/5668639101419520/5671464854355968
Lesson: https://www.educative.io/collection/page/5668639101419520/5671464854355968/5239377766645760

Hi @Harsh_Sharma
I tried the solution myself and it passes all test cases. If you are coping pasting check if there are any indentation changes.

Yes, code that passes the provided 2 test cases may not pass LC. It’s a good idea to run your code in LC.


Course: Grokking the Coding Interview: Patterns for Coding Questions - Learn Interactively
Lesson: Fruits into Baskets (medium) - Grokking the Coding Interview: Patterns for Coding Questions