mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-09 15:28:54 +08:00
Retranslate the complete Japanese online edition from Chinese (#2008)
* Retranslate the complete Japanese online edition from Chinese * Fit Japanese homepage labels and localize heading permalinks * Point Japanese contribution instructions to the Japanese preview * Replace locale conditionals with multilingual UI tables
This commit is contained in:
@@ -6,37 +6,37 @@ Author: Peng Chen (pengchzn@gmail.com)
|
||||
|
||||
from collections import deque
|
||||
|
||||
"""Driver Code"""
|
||||
"""実行用コード"""
|
||||
if __name__ == "__main__":
|
||||
# 両端キューを初期化
|
||||
# 両端キューを初期化する
|
||||
deq: deque[int] = deque()
|
||||
|
||||
# 要素をエンキュー
|
||||
deq.append(2) # 末尾に追加する
|
||||
# 要素をエンキューする
|
||||
deq.append(2) # キューの末尾に追加する
|
||||
deq.append(5)
|
||||
deq.append(4)
|
||||
deq.appendleft(3) # 先頭に追加する
|
||||
deq.appendleft(3) # キューの先頭に追加する
|
||||
deq.appendleft(1)
|
||||
print("両端キュー deque =", deq)
|
||||
|
||||
# 要素にアクセス
|
||||
front: int = deq[0] # 先頭要素
|
||||
print("先頭要素 front =", front)
|
||||
rear: int = deq[-1] # 末尾要素
|
||||
print("末尾要素 rear =", rear)
|
||||
# 要素にアクセスする
|
||||
front: int = deq[0] # キューの先頭要素
|
||||
print("キューの先頭要素 front =", front)
|
||||
rear: int = deq[-1] # キューの末尾要素
|
||||
print("キューの末尾要素 rear =", rear)
|
||||
|
||||
# 要素をデキュー
|
||||
pop_front: int = deq.popleft() # 先頭要素を取り出す
|
||||
print("先頭から取り出した要素 pop_front =", pop_front)
|
||||
print("先頭から取り出した後 deque =", deq)
|
||||
pop_rear: int = deq.pop() # 末尾要素を取り出す
|
||||
print("末尾から取り出した要素 pop_rear =", pop_rear)
|
||||
print("末尾から取り出した後 deque =", deq)
|
||||
# 要素をデキューする
|
||||
pop_front: int = deq.popleft() # キューの先頭要素をデキューする
|
||||
print("先頭からデキューした要素 pop_front =", pop_front)
|
||||
print("先頭からデキューした後 deque =", deq)
|
||||
pop_rear: int = deq.pop() # キューの末尾要素をデキューする
|
||||
print("末尾からデキューした要素 pop_rear =", pop_rear)
|
||||
print("末尾からデキューした後 deque =", deq)
|
||||
|
||||
# 両端キューの長さを取得
|
||||
# 両端キューの長さを取得する
|
||||
size: int = len(deq)
|
||||
print("両端キューの長さ size =", size)
|
||||
|
||||
# 両端キューが空かどうかを判定
|
||||
# 両端キューが空かどうかを判定する
|
||||
is_empty: bool = len(deq) == 0
|
||||
print("両端キューが空かどうか =", is_empty)
|
||||
print("両端キューは空か =", is_empty)
|
||||
|
||||
Reference in New Issue
Block a user