Code passing custom examples not test cases

here is my code:


pls check for error why isn’t it passing test cases

Hello @Garvit012,

Your code is failing for test cases like:
Example 1:
1
9
5 3 1 1 2 3 3 2 1
Expected Output:
7: 1 1 2 3 3 2 1
Yours Output:
6 : 1 2 3 3 2 1

Example 2:
1
10
5 3 1 1 1 2 3 3 2 1
Expected Output:
8: 1 1 1 2 3 3 2 1
Yours Output:
6 : 1 2 3 3 2 1

Hope, this would help.

Hello @Garvit012,

Now it is failing for test cases like:

  1. 1
    10
    Expected Output:
    1
    Your Output:
    0

  2. And also failing for large inputs.

You can refer to the following approach with is less ambiguous: