do we do a level-order traveresal, store items at each level in an array, reverse the arrays in odd indices and finally merge all item to a new array?
@CodeHarmonydev6 күн бұрын
Yes , correct
@CodeHarmonydev6 күн бұрын
Reverse the array wont be the correct statement, in short we are trying to make array sorted by utilising swap operations. Given an array , do minimum number of swap operations on any two Indus to make the array sorted. This becomes our hidden problem inside this question. And the approach that we have to follow is to a rate over the array, and try to bring the exact value at the particular index. If the value is already correct, we don’t require a swap else we require one swap. I hope you got more clarity on this now . Let me know.