본문 바로가기
python-algorithm

leetcode 2022. Convert 1D Array Into 2D Array

by 무적김두칠 2022. 7. 11.

1
2
3
4
5
6
7
8
9
10
11
12
13
class Solution:
    def construct2DArray(self, original: List[int], m: int, n: int-> List[List[int]]:
        output=[]
        n_original=len(original)
        if n_original/!= n :
            return output
        else :
            for i in range(m):
                tmp_list=[]
                for j in range(n):
                    tmp_list.append(original[n*i+j])
                output.append(tmp_list)
            return output
cs
반응형

댓글