Showing:
Handle Score
@Ibrahim Nash 5761
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4944
@saiujwal13083 4506
@sanjay05 3762
@marius_valentin_dragoi 3516
@sushant_a 3459
@verma_ji 3341
@KshamaGupta 3318
C++ 2-D Arrays | Set-1
School Accuracy: 29.41% Submissions: 17 Points: 0

Given an 2-d array of integers having N*N elements, print the transpose of the array.

Example 1:

â€‹Input : arr[] = {{1,2,3}, {4,5,6}, {7,8,9}}
and N = 3
Output : 1 4 7 2 5 8 3 6 9
Explanation:
1 2 3       1 4 7
4 5 6 ----> 2 5 8
7 8 9       3 6 9
Transpose of array.


â€‹Example 2:

Input : arr[ ] = {{1, 2}, {1, 2}} and N = 2
Output :  1 1 2 2

This is a function problem. The input is already taken care of by the driver code. You only need to complete the function transpose() that takes a two-dimension array (arr), sizeOfArray (n), and return the transpose of the array. The driver code takes care of the printing.

Expected Time Complexity: O(N2).
Expected Auxiliary Space: O(1).

Constraints:
1 ≤ N ≤ 100
0 ≤ A[i] ≤ 1000