please provide me a testcase

It’s showing wrong answer.

Can anyone help me that why i am getting a wrong answer or provide me a testcase where my soln fails?



2 1 1 2

Expected output:


Your Output:


1 Like

Simple solution:

Click to view

Run a loop from start to end and count number of odd numbers in array. Also note first and last index of an odd number.

if count is even, answer is N

else answer is max(N - left, right-1) (1-based indexing)

Solution Link:


How did you made that button?

alt text

@kunnu120, See this sign adjacent to Bold and Italic options. Just click there and magic…

Click to view

Couldn’t ad image to comment, so posted a new answer… :slight_smile:

See answer below…

Click to view

Thank you taran_1407 (ಥـْـِـِـِـْಥ)


No problem. :smiley: