Solution Review: Index Array
Let’s take a detailed look at the previous challenge’s solution.
We'll cover the following
First solution
We’ll use nested loops:
- The outer loop will help us store the value of index
i
incurr
. - In the inner loop, we have to swap the values to the respective index position in the array. If that position is not available, we have to place
-1
there.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.