Compact a given array problem
- by Bragaadeesh
Dont know whether this is a duplicate, but this was an interview question asked to me. Given an array of random numbers and -1 placed inbetween, I have to compact the array meaning all the -1s are to be replaced and the final output should be the last valid index with the fresh array. For example.
Input:
3 4 -1 -1 -1 5 8 -1 8
Output:
3 4 5 8 8 5 8…