mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-06 09:23:19 +08:00
Add solution 2022
This commit is contained in:
@ -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
|
||||
}
|
Reference in New Issue
Block a user