mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-07 06:44:57 +08:00
Add python code of chapter queue to docs.
This commit is contained in:
@ -36,9 +36,10 @@ class MyList:
|
||||
assert index < self.__size, "索引越界"
|
||||
self.__nums[index] = num
|
||||
|
||||
""" 中间插入元素 """
|
||||
""" 中间插入(尾部添加)元素 """
|
||||
def add(self, num, index=-1):
|
||||
assert index < self.__size, "索引越界"
|
||||
# 若不指定索引 index ,则向数组尾部添加元素
|
||||
if index == -1:
|
||||
index = self.__size
|
||||
# 元素数量超出容量时,触发扩容机制
|
||||
|
Reference in New Issue
Block a user