Reorder array according to given index
问题 Algorithm reorder array according to given index a[] = [50, 40, 70, 60, 90] index[] = [3, 0, 4, 1, 2] a= [60,50,90,40,70] in O(n) and With out extra array/spaces 回答1: You'll need space for a temp variable and loop counters / indices. The usual "reorder" according to algorithm is also going to change index[] back to {0, 1, 2, 3, 4}. Hint, noting the ordering of indices in index[]. {0, 1, 2, 3, 4} index[] = {3, 0, 4, 1, 2} The reordering can be done by following the "cycles". Start with index[0