Question: Given array of size N, containing elements from 0 to N-1. All values from 0 to N-1 are present in array and if they are

Given array of size N, containing elements from 0 to N-1. All values from 0 to N-1 are present in array and if they are not there then -1 is there to take its place. Arrange values of array so that value i is stored at arr[i].

Input: [8, -1, 6, 1, 9, 3, 2, 7, 4, -1]

Output: [-1, 1, 2, 3, 4, -1, 6, 7, 8, 9]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!