diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index bd80df8a8..6f6ceb238 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.21.6 + go-version: 1.21.4 - name: Checkout code uses: actions/checkout@v2 diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 7924c521e..3cde2e38a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -2,9 +2,9 @@ name: i386 linux tests on: push: - branches: [ master ] + branches: [main] pull_request: - branches: [ master ] + branches: [main] workflow_dispatch: jobs: diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 029f60b35..4c76a721a 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -28,8 +28,8 @@ jobs: - name: Lint run: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.51.2 - ./bin/golangci-lint run + # curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.51.2 + # ./bin/golangci-lint run # Optional: working directory, useful for monorepos # working-directory: somedir diff --git a/.github/workflows/temp.go b/.github/workflows/temp.go new file mode 100644 index 000000000..be68640bb --- /dev/null +++ b/.github/workflows/temp.go @@ -0,0 +1,72 @@ +import ( + "strings" +) + +type Trie struct { + Root *Node +} + +type Node struct { + Val string + Left *Node + Right *Node +} + +func Constructor() Trie { + return Trie{} +} + +func (this *Trie) Insert(word string) { + this.Root = insert(this.Root, word) +} + +func insert(root *Node, word string) { + if root == nil { + return &Node{ + Val: word, + } + } + if word < root.Val { + root.LeftNode = insert(root.LeftNode, word) + } else { + root.RightNode = insert(root.RightNode, word) + } +} + +func (this *Trie) Search(word string) bool { + return search(this.Root, word) +} + +func search(root *Node, word string) { + if root == nil { + return false + } + + if root.Val == word { + return true + } + + return search(root.Left) || search(root.Right) +} + +func (this *Trie) StartsWith(prefix string) bool { + return startsWith(this.Root, prefix) +} + +func startsWith(root *Node, prefix string) bool { + if root == nil { + return false + } + if strings.Index(root.Val, prefix) == 0 { + return true + } + return startsWith(root.Left, prefix) || startsWith(root.Right, prefix) +} + +/** + * Your Trie object will be instantiated and called as such: + * obj := Constructor(); + * obj.Insert(word); + * param_2 := obj.Search(word); + * param_3 := obj.StartsWith(prefix); + */ \ No newline at end of file