Permutations
Permutation is like all the possibilities of the given number or the given string or any thing
Suppose there's a character of ABC
Then the possibilities of this is :-
ACB
BAC
BCA
CAB
CBA,
But,
Suppose we have to built an array from the permutations then the process will be like :-
[0,2,1,5,3,4]
Which means the on the index number whatever the number is present for example suppose on the 3rd index number the number which is present is 5 so we'll check inside that given array like on the 5th index number whichever the number is present we have to put that number on that index.
So,
in our case on the 5th index the number present there is 4.
So, Whatever the number present inside the given array that number we have to store to the ith index number
The final output of the modified array is [0,1,2,4,5,3].
But,
the main question is can we modify the the given array itself by manipulating the existing array or we have to create another array for it?
We can apply both things on the given array like we can do either modifying that the given array or by creating the new array.
Subscribe to my newsletter
Read articles from Rohit kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by