Revert the runnable-snippets batches to the #2033 state (#2038)

Reverts #2034, #2035, #2036 and #2037. The work will return in a single
reviewed PR that is completed before it merges. The tree equals 8c96e2f30
(#2033).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Yudong Jin
2026-11-16 06:45:32 +08:00
committed by GitHub
co-authored by Claude Opus 5.5
parent b113cb425a
commit ded7ddc635
918 changed files with 16854 additions and 13700 deletions
@@ -4,50 +4,36 @@ Created Time: 2022-11-29
Author: Peng Chen ([email protected])
"""
# [region]{import_deque}
from collections import deque
# [endregion]{import_deque}
"""Driver code"""
if __name__ == "__main__":
# [region]{init_queue}
# Initialize the queue
# In Python, we generally use the deque class as a queue
# Although queue.Queue() is a dedicated queue class, deque is more convenient for this example
que: deque[int] = deque()
# [endregion]{init_queue}
# [region]{push}
# Enqueue elements
que.append(1)
que.append(3)
que.append(2)
que.append(5)
que.append(4)
# [endregion]{push}
print("Queue que =", que)
# [region]{peek}
# Access the front element
front: int = que[0]
# [endregion]{peek}
print("Front element front =", front)
# [region]{pop}
# Dequeue an element
pop: int = que.popleft()
# [endregion]{pop}
print("Dequeued element pop =", pop)
print("After dequeuing, que =", que)
# [region]{size}
# Get the queue size
size: int = len(que)
# [endregion]{size}
print("Queue size =", size)
# [region]{is_empty}
# Check whether the queue is empty
is_empty: bool = len(que) == 0
# [endregion]{is_empty}
print("Is the queue empty =", is_empty)