Add build script for Go and update Go codes.

This commit is contained in:
krahets
2023-02-09 04:45:06 +08:00
parent 12c085a088
commit e8c78f89f0
39 changed files with 391 additions and 1468 deletions

View File

@ -33,18 +33,7 @@ comments: true
=== "Go"
```go title="linear_search.go"
/* 线性查找(数组) */
func linearSearchArray(nums []int, target int) int {
// 遍历数组
for i := 0; i < len(nums); i++ {
// 找到目标元素,返回其索引
if nums[i] == target {
return i
}
}
// 未找到目标元素,返回 -1
return -1
}
[class]{}-[func]{linearSearchArray}
```
=== "JavaScript"
@ -106,19 +95,7 @@ comments: true
=== "Go"
```go title="linear_search.go"
/* 线性查找(链表)*/
func linerSearchLinkedList(node *ListNode, target int) *ListNode {
// 遍历链表
for node != nil {
// 找到目标结点,返回之
if node.Val == target {
return node
}
node = node.Next
}
// 未找到目标元素,返回 nil
return nil
}
[class]{}-[func]{linearSearchLinkedList}
```
=== "JavaScript"