Add solution 2022

This commit is contained in:
halfrost
2021-12-27 21:21:21 +08:00
parent 1a959a2ace
commit 2a94da0c1d
3 changed files with 153 additions and 0 deletions

View File

@ -0,0 +1,12 @@
package leetcode
func construct2DArray(original []int, m int, n int) [][]int {
if m*n != len(original) {
return [][]int{}
}
res := make([][]int, m)
for i := 0; i < m; i++ {
res[i] = original[n*i : n*(i+1)]
}
return res
}