Order mismatch between Solution 1 and Solution 2

Both the solutions offered for this question are giving different output.
The solution using auxilary arrays gives the correct output [ -1, -9, -6, 10, 20, 4, 5 ]
But the solution 2 using inplace swapping gives [ -1, -9, -6, 4, 5, 10, 20 ].
In solution 2, the order of positive numbers in the original array and the output has changed and since it was not explicitly called out in the question, it should maintain the order.

Hi @Raghava_Deekshitula !!
The order of the numbers is not important as long as all negative numbers are grouped together on the left and all positive ones on the right. For example, both of the following are valid outputs for the same input:[-23,1,-2,0,44,-9,8]

  • [-23,-2,-9,0,44,1,8]
  • [-23,-9,-2,0,1,44,8]
    I hope it helps. Happy Learning :blush: