Bug fixes and improvements (#1318)

* Sync zh and zh-hant versions

* Update en/README.md

* Add a Q&A for chapter of introduction

* Update the callout headers

* Sync zh ang zh-hant versions

* Bug fixes
This commit is contained in:
Yudong Jin
2024-04-30 15:52:05 +08:00
committed by GitHub
parent 84b1ce2497
commit 870e3e5cb2
107 changed files with 779 additions and 87 deletions

View File

@@ -27,28 +27,28 @@
from collections import deque
# 初始化双向队列
deque: deque[int] = deque()
deq: deque[int] = deque()
# 元素入队
deque.append(2) # 添加至队尾
deque.append(5)
deque.append(4)
deque.appendleft(3) # 添加至队首
deque.appendleft(1)
deq.append(2) # 添加至队尾
deq.append(5)
deq.append(4)
deq.appendleft(3) # 添加至队首
deq.appendleft(1)
# 访问元素
front: int = deque[0] # 队首元素
rear: int = deque[-1] # 队尾元素
front: int = deq[0] # 队首元素
rear: int = deq[-1] # 队尾元素
# 元素出队
pop_front: int = deque.popleft() # 队首元素出队
pop_rear: int = deque.pop() # 队尾元素出队
pop_front: int = deq.popleft() # 队首元素出队
pop_rear: int = deq.pop() # 队尾元素出队
# 获取双向队列的长度
size: int = len(deque)
size: int = len(deq)
# 判断双向队列是否为空
is_empty: bool = len(deque) == 0
is_empty: bool = len(deq) == 0
```
=== "C++"