diff --git a/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/116.Populating Next Right Pointers in Each Node.go b/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/116.Populating Next Right Pointers in Each Node.go index fdaa074c..4587c39d 100644 --- a/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/116.Populating Next Right Pointers in Each Node.go +++ b/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/116.Populating Next Right Pointers in Each Node.go @@ -7,7 +7,7 @@ type Node struct { Next *Node } -//解法一:迭代 +// 解法一:迭代 func connect(root *Node) *Node { if root == nil { return root diff --git a/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/116.Populating Next Right Pointers in Each Node_test.go b/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/116.Populating Next Right Pointers in Each Node_test.go index c156db29..6146f157 100644 --- a/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/116.Populating Next Right Pointers in Each Node_test.go +++ b/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/116.Populating Next Right Pointers in Each Node_test.go @@ -22,7 +22,7 @@ type ans116 struct { one *Node } -func newQuestionNode()*Node{ +func newQuestionNode() *Node { node7 := &Node{} node7.Val = 7 @@ -55,7 +55,7 @@ func newQuestionNode()*Node{ return node1 } -func newResultNode()*Node{ +func newResultNode() *Node { node7 := &Node{} node7.Val = 7 @@ -114,4 +114,4 @@ func Test_Problem116(t *testing.T) { fmt.Printf("【output】:%v \n", connect(p.one)) } fmt.Printf("\n\n\n") -} \ No newline at end of file +} diff --git a/leetcode/0306.Additive-Number/306. Additive Number.go b/leetcode/0306.Additive-Number/306. Additive Number.go index 1489b05c..bd0429a1 100644 --- a/leetcode/0306.Additive-Number/306. Additive Number.go +++ b/leetcode/0306.Additive-Number/306. Additive Number.go @@ -35,7 +35,7 @@ func max(a int, b int) int { return b } -//Propagate for rest of the string +// Propagate for rest of the string func recursiveCheck(num string, x1 int, x2 int, left int) bool { if left == len(num) { return true diff --git a/leetcode/0372.Super-Pow/372. Super Pow.go b/leetcode/0372.Super-Pow/372. Super Pow.go index aacc6c7a..3f4082c7 100644 --- a/leetcode/0372.Super-Pow/372. Super Pow.go +++ b/leetcode/0372.Super-Pow/372. Super Pow.go @@ -8,10 +8,11 @@ package leetcode // 模运算性质五:ab % p = ((a % p) * ( b % p)) % p, 其中 ab 是一个数字,如:2874,98374 等等 // 举个例子 // 12345^678 % 1337 = (12345^670 * 12345^8) % 1337 -// = ((12345^670 % 1337) * (12345^8 % 1337)) % 1337 ---> 利用性质 三 +// +// = ((12345^670 % 1337) * (12345^8 % 1337)) % 1337 ---> 利用性质 三 // = (((12345^67)^10 % 1337) * (12345^8 % 1337)) % 1337 ---> 乘方性质 -// = ((12345^67 % 1337)^10) % 1337 * (12345^8 % 1337)) % 1337 ---> 利用性质 四 -// = (((12345^67 % 1337)^10) * (12345^8 % 1337)) % 1337 ---> 反向利用性质 三 +// = ((12345^67 % 1337)^10) % 1337 * (12345^8 % 1337)) % 1337 ---> 利用性质 四 +// = (((12345^67 % 1337)^10) * (12345^8 % 1337)) % 1337 ---> 反向利用性质 三 func superPow(a int, b []int) int { res := 1 for i := 0; i < len(b); i++ { diff --git a/leetcode/0401.Binary-Watch/401. Binary Watch.go b/leetcode/0401.Binary-Watch/401. Binary Watch.go index 88b49e53..39cbf839 100644 --- a/leetcode/0401.Binary-Watch/401. Binary Watch.go +++ b/leetcode/0401.Binary-Watch/401. Binary Watch.go @@ -76,11 +76,11 @@ func readBinaryWatch1(num int) []string { return res } -/// --------------------------------------- -/// --------------------------------------- -/// --------------------------------------- -/// --------------------------------------- -/// --------------------------------------- +// / --------------------------------------- +// / --------------------------------------- +// / --------------------------------------- +// / --------------------------------------- +// / --------------------------------------- // 以下是打表用到的函数 // 调用 findReadBinaryWatchMinute(num, 0, c, &res) 打表 func findReadBinaryWatchMinute(target, index int, c []int, res *[]string) { diff --git a/leetcode/0509.Fibonacci-Number/509. Fibonacci Number.go b/leetcode/0509.Fibonacci-Number/509. Fibonacci Number.go index 9fc98a9b..ea6d95a2 100644 --- a/leetcode/0509.Fibonacci-Number/509. Fibonacci Number.go +++ b/leetcode/0509.Fibonacci-Number/509. Fibonacci Number.go @@ -111,19 +111,19 @@ func fib5(N int) int { // 解法七 协程版,但是时间特别慢,不推荐,放在这里只是告诉大家,写 LeetCode 算法题的时候,启动 goroutine 特别慢 func fib6(N int) int { - return <-fibb(N) + return <-fibb(N) } -func fibb(n int) <- chan int { - result := make(chan int) - go func() { - defer close(result) - - if n <= 1 { - result <- n - return - } - result <- <-fibb(n-1) + <-fibb(n-2) - }() - return result -} \ No newline at end of file +func fibb(n int) <-chan int { + result := make(chan int) + go func() { + defer close(result) + + if n <= 1 { + result <- n + return + } + result <- <-fibb(n-1) + <-fibb(n-2) + }() + return result +} diff --git a/leetcode/0589.N-ary-Tree-Preorder-Traversal/589. N-ary Tree Preorder Traversal.go b/leetcode/0589.N-ary-Tree-Preorder-Traversal/589. N-ary Tree Preorder Traversal.go index 8daad2aa..c0059ffd 100644 --- a/leetcode/0589.N-ary-Tree-Preorder-Traversal/589. N-ary Tree Preorder Traversal.go +++ b/leetcode/0589.N-ary-Tree-Preorder-Traversal/589. N-ary Tree Preorder Traversal.go @@ -1,6 +1,6 @@ package leetcode -// Definition for a Node. +// Definition for a Node. type Node struct { Val int Children []*Node diff --git a/leetcode/0648.Replace-Words/648. Replace Words.go b/leetcode/0648.Replace-Words/648. Replace Words.go index d742af98..0d26e075 100644 --- a/leetcode/0648.Replace-Words/648. Replace Words.go +++ b/leetcode/0648.Replace-Words/648. Replace Words.go @@ -34,7 +34,7 @@ func findWord(roots map[byte][]string, word []byte) bool { return false } -//解法二 Trie +// 解法二 Trie func replaceWords1(dict []string, sentence string) string { trie := Constructor208() for _, v := range dict {