Created
July 28, 2021 15:35
-
-
Save dongwooklee96/490ad57f7e803ca8b9c251953f0e4764 to your computer and use it in GitHub Desktop.
8.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| 문제 : 버블 정렬을 구현하시오. | |
| """ | |
| from typing import List | |
| def bubble_sort(arr: List[int]): | |
| n = len(arr) | |
| for i in range(n): | |
| done_sort = True | |
| for j in range(n - i - 1): | |
| if arr[j] > arr[j + 1]: | |
| arr[j], arr[j + 1] = arr[j + 1], arr[j] | |
| done_sort = False | |
| if done_sort: | |
| break | |
| return arr | |
| if __name__ == "__main__": | |
| lists = list(map(int, input().split())) | |
| print(bubble_sort(lists)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment