Using modulo to go to the firs column after the last column
ans [ i ] [ j ] = arr [ j ] [ ( i + j ) % n ] ; } } return ans ; } void show ( vector < vector < int > > arr , int n ) { vector < vector < int > > res = solve ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { cout << res [ i ] [ j ] << " ▁ " ; } cout << endl ; } }