Skip to content

Commit 55fd5c0

Browse files
committed
FIX GO_LINT
1 parent 7772157 commit 55fd5c0

File tree

162 files changed

+435
-447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+435
-447
lines changed

Algorithms/0007. Reverse Integer/7. Reverse Integer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package leetcode
22

3-
func reverse_7(x int) int {
3+
func reverse7(x int) int {
44
tmp := 0
55
for x != 0 {
66
tmp = tmp*10 + x%10

Algorithms/0007. Reverse Integer/7. Reverse Integer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func Test_Problem7(t *testing.T) {
5151

5252
for _, q := range qs {
5353
_, p := q.ans7, q.para7
54-
fmt.Printf("【input】:%v 【output】:%v\n", p.one, reverse_7(p.one))
54+
fmt.Printf("【input】:%v 【output】:%v\n", p.one, reverse7(p.one))
5555
}
5656
fmt.Printf("\n\n\n")
5757
}

Algorithms/0015. 3Sum/15. 3Sum.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func threeSum(nums []int) [][]int {
1212
}
1313

1414
uniqNums := []int{}
15-
for key, _ := range counter {
15+
for key := range counter {
1616
uniqNums = append(uniqNums, key)
1717
}
1818
sort.Ints(uniqNums)

Algorithms/0016. 3Sum Closest/16. 3Sum Closest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func threeSumClosest(nums []int, target int) int {
3030
}
3131

3232
// 解法二 暴力解法 O(n^3)
33-
func threeSumClosest_(nums []int, target int) int {
33+
func threeSumClosest1(nums []int, target int) int {
3434
res, difference := 0, math.MaxInt16
3535
for i := 0; i < len(nums); i++ {
3636
for j := i + 1; j < len(nums); j++ {

Algorithms/0018. 4Sum/18. 4Sum.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func fourSum(nums []int, target int) [][]int {
1010
}
1111

1212
uniqNums := []int{}
13-
for key, _ := range counter {
13+
for key := range counter {
1414
uniqNums = append(uniqNums, key)
1515
}
1616
sort.Ints(uniqNums)

Algorithms/0019. Remove Nth Node From End of List/19. Remove Nth Node From End of List.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func removeNthFromEnd(head *ListNode, n int) *ListNode {
2929
}
3030

3131
// 解法二
32-
func removeNthFromEnd_(head *ListNode, n int) *ListNode {
32+
func removeNthFromEnd1(head *ListNode, n int) *ListNode {
3333
if head == nil {
3434
return nil
3535
}

Algorithms/0021. Merge Two Sorted Lists/21. Merge Two Sorted Lists.go

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,56 +17,7 @@ func mergeTwoLists(l1 *ListNode, l2 *ListNode) *ListNode {
1717
if l1.Val < l2.Val {
1818
l1.Next = mergeTwoLists(l1.Next, l2)
1919
return l1
20-
} else {
21-
l2.Next = mergeTwoLists(l1, l2.Next)
22-
return l2
2320
}
24-
// if l1 == nil && l2 == nil {
25-
// return nil
26-
// }
27-
// head := &ListNode{Val: 0, Next: nil}
28-
// current := head
29-
// var currentl1, currentl2 *ListNode
30-
// for l1 != nil || l2 != nil {
31-
// if l1 != nil {
32-
// currentl1 = &ListNode{Val: l1.Val, Next: nil}
33-
// }
34-
// if l2 != nil {
35-
// currentl2 = &ListNode{Val: l2.Val, Next: nil}
36-
// }
37-
38-
// if l1 == nil && l2 != nil {
39-
// current.Next = currentl2
40-
// current = currentl2
41-
// l2 = l2.Next
42-
// continue
43-
// } else if l2 == nil && l1 != nil {
44-
// current.Next = currentl1
45-
// current = currentl1
46-
// l1 = l1.Next
47-
// continue
48-
// } else if l2 == nil && l1 == nil {
49-
// return head.Next
50-
// } else {
51-
// if currentl1.Val < currentl2.Val {
52-
// current.Next = currentl1
53-
// current = currentl1
54-
// l1 = l1.Next
55-
// continue
56-
// } else if currentl1.Val == currentl2.Val {
57-
// current.Next = currentl2
58-
// currentl2.Next = currentl1
59-
// current = currentl1
60-
// l1 = l1.Next
61-
// l2 = l2.Next
62-
// continue
63-
// } else {
64-
// current.Next = currentl2
65-
// current = currentl2
66-
// l2 = l2.Next
67-
// continue
68-
// }
69-
// }
70-
// }
71-
// return head.Next
21+
l2.Next = mergeTwoLists(l1, l2.Next)
22+
return l2
7223
}

Algorithms/0023. Merge k Sorted Lists/23. Merge k Sorted Lists.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ func mergeTwoLists1(l1 *ListNode, l2 *ListNode) *ListNode {
3131
if l1.Val < l2.Val {
3232
l1.Next = mergeTwoLists1(l1.Next, l2)
3333
return l1
34-
} else {
35-
l2.Next = mergeTwoLists1(l1, l2.Next)
36-
return l2
3734
}
35+
l2.Next = mergeTwoLists1(l1, l2.Next)
36+
return l2
3837
}

Algorithms/0026. Remove Duplicates from Sorted Array/26. Remove Duplicates from Sorted Array.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ func removeDuplicates(nums []int) int {
1414
}
1515
}
1616
nums[last+1] = nums[finder]
17-
last += 1
17+
last++
1818
}
1919
return last + 1
2020
}
2121

2222
// 解法二
23-
func removeDuplicates_(nums []int) int {
23+
func removeDuplicates1(nums []int) int {
2424
if len(nums) == 0 {
2525
return 0
2626
}
@@ -32,14 +32,14 @@ func removeDuplicates_(nums []int) int {
3232
break
3333
}
3434
if nums[i+1] == nums[i] {
35-
removeElement_(nums, i+1, nums[i])
35+
removeElement1(nums, i+1, nums[i])
3636
// fmt.Printf("此时 num = %v length = %v\n", nums, length)
3737
}
3838
}
3939
return i + 1
4040
}
4141

42-
func removeElement_(nums []int, start, val int) int {
42+
func removeElement1(nums []int, start, val int) int {
4343
if len(nums) == 0 {
4444
return 0
4545
}

Algorithms/0028. Implement strStr()/28. Implement strStr().go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ func strStr(haystack string, needle string) int {
2020
}
2121

2222
// 解法二
23-
func strStr_(haystack string, needle string) int {
23+
func strStr1(haystack string, needle string) int {
2424
return strings.Index(haystack, needle)
2525
}

0 commit comments

Comments
 (0)