Given a list of integers arr, implement the bubble sort algorithm to sort the list in non-decreasing order. Bubble sort works by repeatedly swapping adjacent elements if they are in the wrong order.
Constraints
1 <= arr.length <= 1000
-10^3 <= arr[i] <= 10^3
Function Signature
defbubble_sort(arr: list[int]) -> list[int]:
Interviewer
Your question is Implement Bubble Sort Algorithm. Start with the requirements in the Question tab.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.