mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-12 23:36:06 +00:00
build
This commit is contained in:
@@ -1200,7 +1200,7 @@ Traverse the linked list to locate a node whose value matches `target`, and then
|
||||
var index = 0
|
||||
var h = head
|
||||
while (h != null) {
|
||||
if (h.value == target)
|
||||
if (h._val == target)
|
||||
return index
|
||||
h = h.next
|
||||
index++
|
||||
|
||||
@@ -2175,7 +2175,7 @@ To enhance our understanding of how lists work, we will attempt to implement a s
|
||||
# 元素数量超出容量时,触发扩容机制
|
||||
extend_capacity if size == capacity
|
||||
@arr[size] = num
|
||||
|
||||
|
||||
# 更新元素数量
|
||||
@size += 1
|
||||
end
|
||||
@@ -2189,7 +2189,7 @@ To enhance our understanding of how lists work, we will attempt to implement a s
|
||||
|
||||
# 将索引 index 以及之后的元素都向后移动一位
|
||||
for j in (size - 1).downto(index)
|
||||
@arr[j + 1] = @arr[j]
|
||||
@arr[j + 1] = @arr[j]
|
||||
end
|
||||
@arr[index] = num
|
||||
|
||||
|
||||
Reference in New Issue
Block a user