Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Implement Bubble Sort Algorithm
00:00
5 left

Implement Bubble Sort Algorithm

EasyPython

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]:
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.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.