mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 00:25:22 +08:00
Fix goreport bug
This commit is contained in:
@ -7,7 +7,7 @@ type Node struct {
|
||||
Next *Node
|
||||
}
|
||||
|
||||
//解法一:迭代
|
||||
// 解法一:迭代
|
||||
func connect(root *Node) *Node {
|
||||
if root == nil {
|
||||
return root
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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++ {
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
}
|
||||
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
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package leetcode
|
||||
|
||||
// Definition for a Node.
|
||||
// Definition for a Node.
|
||||
type Node struct {
|
||||
Val int
|
||||
Children []*Node
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user