Skip to content

Commit 78f80a0

Browse files
limingzhonglimingzhong
authored andcommitted
fx
1 parent b0f988c commit 78f80a0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/nums/nums.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package nums
22

3-
import "sort"
3+
import _ "sort"
44

55
func SubSets(nums []int) [][]int {
66
if len(nums) == 0 {
@@ -68,3 +68,10 @@ func Combine(n, k int) [][]int {
6868

6969
return res
7070
}
71+
72+
func deleteItem(nums []int, i int) []int {
73+
l := make([]int, i)
74+
copy(l, nums)
75+
l = append(l, nums[i+1:]...)
76+
return l
77+
}

src/nums/nums_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ func TestSubSets(t *testing.T) {
1313
func TestCombine(t *testing.T) {
1414
fmt.Println(Combine(4, 2))
1515
}
16+
17+
func TestDeleteItem(t *testing.T) {
18+
fmt.Println(deleteItem([]int{1, 2, 3, 4}, 2))
19+
}

0 commit comments

Comments
 (0)