Reverse Array in Groups
Problem Statement
Given an array arr[] of positive integers of size N. Reverse every sub-array group of size K.
Note: If at any instance, there are no more subarrays of size greater than or equal to K, then reverse the last subarray (irrespective of its size).
Example 1
Example 2
Task
You don't need to read input or print anything. The task is to complete the function reverseInGroups() which takes the array, N and K as input parameters and modifies the array in-place.
Expected Time Complexity : O(N)
Expected Auxiliary Space : O(N)
Constraints :
1 <= N <= 107
1 <= A[i] <= 1018
0 Comments