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?

1

4

2 1 1 2

Expected output:

4

Your Output:

2

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: CodeChef: Practical coding for everyone

2 Likes

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:

Click to view

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

How did you made that button?

See answer below…

@taran_1407

No problem. :smiley: