Error
|
|
---|---|
@Ibrahim Nash | 5761 |
@blackshadows | 5701 |
@akhayrutdinov | 5111 |
@mb1973 | 4989 |
@Quandray | 4944 |
@saiujwal13083 | 4506 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3516 |
@sushant_a | 3459 |
@verma_ji | 3341 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@aroranayan999 | 938 |
@bt8816103042 | 739 |
@SHOAIBVIJAPURE | 428 |
@codeantik | 412 |
@SherlockHolmes3 | 407 |
@neverevergiveup | 348 |
@mahlawatep | 347 |
@shalinibhataniya1097 | 343 |
@murarry3625 | 333 |
@saiujwal13083 | 326 |
@rohitanand | 314 |
Complete Leaderboard |
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
Your Task:
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
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes