Move a set of elements (represented by start and end indexed) in an array to a given destination location (destination index).
Example:
Let say our array is {9, 7, 5, 8, 1, 5, 4, 8, 10, 1}
move_set (array, start = 1, end = 3, destination = 8)
Should rearrage the array such that the new array looks like {9, 1, 5,4, 8, 10, 7, 5, 8, 1}
This is just like exchanging first and second subset where first subset is from 1(start) to 3(end) and second subset is 4(end+1) to 8(destination)
Refer : Swap two words in a given sentence.
Example:
Let say our array is {9, 7, 5, 8, 1, 5, 4, 8, 10, 1}
move_set (array, start = 1, end = 3, destination = 8)
Should rearrage the array such that the new array looks like {9, 1, 5,4, 8, 10, 7, 5, 8, 1}
This is just like exchanging first and second subset where first subset is from 1(start) to 3(end) and second subset is 4(end+1) to 8(destination)
Refer : Swap two words in a given sentence.
No comments:
Post a Comment