Transpose a grid · 행렬 전치
Transpose a grid
Swap the rows and columns of a grid, as if you reflected a table across its diagonal.
grid[r][c] is the item in row r and column c. The new grid has one row for each column of the old one, so loop over the column numbers first, and inside that loop collect row[col] from every row.
격자 전치(Transposition)
테이블을 대각선을 따라 반사한 것처럼 격자의 행과 열을 교차시킵니다.
grid[r][c]은 행 r과 열 c에 있는 항목입니다. 새 격자는 이전 격자의 각 열에 대해 하나의 행을 가지므로, 먼저 열 번호를 순회하고 그 내부 루프에서 모든 행에서 row[col]을 수집합니다.
Write transpose(grid) that turns rows into columns. grid is a list of rows, all the same length. [[1, 2, 3], [4, 5, 6]] becomes [[1, 4], [2, 5], [3, 6]]. · 행(row)을 열(column)로 바꾸는 transpose(grid)을 작성하십시오. grid은 모든 길이가 동일한 행의 list입니다. [[1, 2, 3], [4, 5, 6]]은 [[1, 4], [2, 5], [3, 6]]으로 바뀝니다.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.