Bubble Sort
Repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. Return the sorted array.

30:00

Bubble Sort
easy
Topics
Companies

Repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. Return the sorted array.

Example 1:
Input: [64,34,25,12,22,11,90]
Output: [11,12,22,25,34,64,90]
Constraints:
  • 1arr.length1041 \leq \text{arr.length} \leq 10^4

  • 109arr[i]109-10^9 \leq \text{arr}[i] \leq 10^9

Input
arr =[64,34,25,12,22,11,90]
640341252123224115906
Variables
VariableValue
n7
DepthFunction Call
1bubbleSort(arr=[7])
0/91