There was an error while loading. Please reload this page.
1 parent 79c13f4 commit a27150cCopy full SHA for a27150c
1 file changed
sorts/pancake_sort.py
@@ -64,13 +64,11 @@ def pancake_sort[T: Comparable](arr: Sequence[T]) -> list[T]:
64
while cur > 1:
65
# Find the index of maximum element in arr[0:cur]
66
max_index = arr.index(max(arr[:cur]))
67
-
68
# Move maximum element to end of current unsorted portion:
69
# 1. Flip to bring max to the beginning
70
arr[: max_index + 1] = reversed(arr[: max_index + 1])
71
# 2. Flip to send max to position cur-1
72
arr[:cur] = reversed(arr[:cur])
73
74
cur -= 1
75
return arr
76
0 commit comments