Algorithms – Rearrange the Array of Given Range N, such that A[i]=i.
Objective: Given a array of length N, in which elements are in the range of 1 to N. All elements may not present in the array. If element is not present , there will be -1 present in the array. Rearrange the array such that A[i]=i and if i is not present, display -1 at that place. See example
Approach: – Time Complexity -O(N), Space Complexity – O(1)