Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Implement Bubble Sort Algorithm

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Implement Bubble Sort Algorithm. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

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

def bubble_sort(arr: list[int]) -> list[int]:
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output