mirror of
https://github.com/krahets/hello-algo.git
synced 2026-09-18 12:37:15 +00:00
Update linear_search and hashing_search.
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
/* 线性查找(数组) */
|
||||
func linerSearchArray(nums []int, target int) int {
|
||||
func linearSearchArray(nums []int, target int) int {
|
||||
// 遍历数组
|
||||
for i := 0; i < len(nums); i++ {
|
||||
// 找到目标元素,返回其索引
|
||||
@@ -22,7 +22,7 @@ func linerSearchArray(nums []int, target int) int {
|
||||
}
|
||||
|
||||
/* 线性查找(链表) */
|
||||
func linerSearchLinkedList(node *ListNode, target int) *ListNode {
|
||||
func linearSearchLinkedList(node *ListNode, target int) *ListNode {
|
||||
// 遍历链表
|
||||
for node != nil {
|
||||
// 找到目标元素,返回其索引
|
||||
|
||||
Reference in New Issue
Block a user