Solutions for Reverse Sub-Array

    • @kristeencoupp91
    • @Ethan, submitted in Python 3, achived 100% score
    
    def solve(arr, k): 
        n = len(arr)
        i = 0
    
        while(i<n): 
    
            left = i  
    
            # To handle case when k is not 
            # multiple of n 
            right = min(i + k - 1, n - 1)  
    
            # Reverse the sub-array [left, right] 
            while (left < right): 
    
                arr[left], arr[right] = arr[right], arr[left] 
                left+= 1; 
                right-=1
            i+= k
        return arr