Reverse every consecutive m elements of the given subarray - Techie Delight
Given an array, reverse every group of consecutive m elements in given subarray of it.
For example, consider array
A[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } and
m = 3,
then for subarray [i, j], where i and j is
i = 1, j = 7 or 8
Output: { 1, 4, 3, 2, 7, 6, 5, 8, 9, 10}
i = 1, j = 9
Output: { 1, 4, 3, 2, 7, 6, 5, 10, 9, 8}
i = 3, j = 5
Output: { 1, 2, 3, 6, 5, 4, 7, 8, 9, 10}
i = 3, j = 4
Output: { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Read full article from Reverse every consecutive m elements of the given subarray - Techie Delight
No comments:
Post a Comment