This is a phone interview question:
Rearrange charArray in place such that it matches the order of intArray.
example:
input:
intArray: {4,2,3,0,1}
charArray:{'A','B','C','D','E'}
expected:
code should change charArray to
{'E','C','D','A','B'}
explanation:
charArray = [charArray [4] ='E',charArray [2]='C',charArray [3]='D',charArray [0]='A',charArray [1]='B'];
[E, C, D, A, B]
You cannot use mapping or any other extra space. You can only make change in place.