can u please help in checking out which test case i am missing.
Unable to pass one test case
1
4
4 3 2 1
for this the o/p
s hould be
1 2 3 4
ur o/p
0 2 3 4
Works fine on other editors though. The logic also seems correct but on coding blocks ide the output is different from that on sublime or any other ide
wait let me check on vs code
u are trying to access -1 index when the array is already sorted
so basically garbage value at arr[i-1] is being swapped with arr[index]
so isliye u are getting a wrong answer in hackerblock
where in vs code , there is some way by which code is getting correct o/p
in all, u need to handle the case when array is already sorted
But if the array is sorted the swap never happens . So the negative index should not come into picture.
u have not put any condition if the array is already sorted ( in decreasing order)
as i have shown with the highlighted part
in case the array is in decreasing order then i = 0 and then u swap ( a[i-1], a[idx])
alright got it ! thank you so much
