-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
63 lines (61 loc) · 2.1 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
easy "LeetCode-Go/interview-easy"
medium "LeetCode-Go/interview-medium"
"flag"
"fmt"
"strconv"
)
func main() {
problemNumber := flag.Int("problem", 1, "problem number")
flag.Parse()
switch *problemNumber {
case 1:
fmt.Println(easy.RemoveDuplicates([]int{2, 7, 11, 15}))
case 2:
fmt.Println(easy.MaxProfit([]int{2, 7, 11, 15}))
case 3:
easy.Rotate([]int{2, 7, 11, 15}, 3)
case 4:
fmt.Println(easy.ContainsDuplicate([]int{2, 7, 11, 15}))
case 5:
fmt.Println(easy.SingleNumber([]int{2, 7, 11, 15}))
case 6:
fmt.Println(easy.Intersect([]int{0, 0, 1}, []int{2, 7, 11, 15}))
case 7:
fmt.Println(easy.PlusOne([]int{0, 0, 1}))
case 8:
easy.MoveZeroes([]int{0, 0, 1})
case 9:
fmt.Println(easy.TwoSum([]int{-3, 4, 3, 90}, 0))
case 10:
fmt.Println(easy.IsValidSudoku([][]byte{{'8', '3', '.', '.', '7', '.', '.', '.', '.'}, {'6', '.', '.', '1', '9', '5', '.', '.', '.'}, {'.', '9', '8', '.', '.', '.', '.', '6', '.'}, {'8', '.', '.', '.', '6', '.', '.', '.', '3'}, {'4', '.', '.', '8', '.', '3', '.', '.', '1'}, {'7', '.', '.', '.', '2', '.', '.', '.', '6'}, {'.', '6', '.', '.', '.', '.', '2', '8', '.'}, {'.', '.', '.', '4', '1', '9', '.', '.', '5'}, {'.', '.', '.', '.', '8', '.', '.', '7', '9'}}))
case 11:
easy.RotateII([][]int{{1, 2}, {3, 4}})
case 12:
easy.ReverseString([]byte{'H', 'a', 'n', 'n', 'a', 'h'})
case 101:
fmt.Println(medium.ThreeSum([]int{0, 0, 0}))
case 102:
medium.SetZeroes([][]int{{0, 0, 0, 5}, {4, 3, 1, 4}, {0, 1, 1, 4}, {1, 2, 1, 3}, {0, 0, 1, 1}})
case 103:
fmt.Println(medium.GroupAnagrams([]string{"eat", "tea", "tan", "ate", "nat", "bat"}))
case 104:
fmt.Println(medium.LengthOfLongestSubstring("nfpdmpi"))
case 105:
fmt.Println(medium.IncreasingTriplet([]int{5, 4, 3, 2, 1}))
case 106:
l1 := medium.ListNode{Val: 2, Next: &medium.ListNode{Val: 4, Next: &medium.ListNode{Val: 3}}}
l2 := medium.ListNode{Val: 5, Next: &medium.ListNode{Val: 6, Next: &medium.ListNode{Val: 4}}}
tt := medium.AddTwoNumbers(&l1, &l2)
s := ""
for {
s = strconv.Itoa(tt.Val) + s
if tt.Next == nil {
break
}
tt = l1.Next
}
fmt.Println(s)
}
}