Failing some test cases and not able to get logic around those

Test cases failing:

  • sample-test-1
  • base-test-2
  • base-test-5
  • perf-test-1
  • perf-test-2

In the first sample test case the input is:
3 5 8 5 10 2 1
With x = 5. So the O/P should be
3 2 1 5 8 5 10
But the O/P pre-defined in txt file is
3 2 1 5 5 8 10

Please help with the above failing test cases. Thank you.

You need to keep all elements greater than X to its right, all elements less than X to its left and group all the Xs together (since they are equal) . So 3 2 1 5 8 5 10 is wrong . However 3 2 1 5 5 8 10 and 3 1 2 5 5 10 8 are correct output. I hope this clarifies your doubt.

1 Like

I didn’t knew about the grouping part. Thank you. Now only these test cases are failing:

  • edge-test-4
  • edge-test-5

Try debugging for this case :

5
1 2 3 4 5
5 

Output : 
1 2 3 4 5

Also try this case :`

3 
3 3 3
3

Output : 
3 3 3

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.

Re-opening this topic as the previously accepted solution was just Un-marked.

Thank you. It worked :slight_smile:

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.