
									 Problem
								
								
									 Solution
								
								
									 Submissions
								
								
							Bubble Sort
								Certification: Basic Level
								Accuracy: 66.67%
								Submissions: 6
								Points: 5
							
							Write a Java program to implement the Bubble Sort algorithm to sort an array of integers in ascending order.
Example 1
- Input: nums = [64, 34, 25, 12, 22, 11, 90]
 - Output: [11, 12, 22, 25, 34, 64, 90]
 
Example 2
- Input: nums = [5, 1, 4, 2, 8]
 - Output: [1, 2, 4, 5, 8]
 
Constraints
- 1 ≤ nums.length ≤ 10^4
 - -10^5 ≤ nums[i] ≤ 10^5
 - Time Complexity: O(n²)
 - Space Complexity: O(1)
 
Editorial
									
												
My Submissions
										All Solutions
									| Lang | Status | Date | Code | 
|---|---|---|---|
| You do not have any submissions for this problem. | |||
| User | Lang | Status | Date | Code | 
|---|---|---|---|---|
| No submissions found. | ||||
Solution Hints
- Compare adjacent elements in the array.
 - Swap elements if they are in the wrong order.
 - Repeat the process for each element of the array.
 - After each pass, the largest element moves to the end.
 - Optimize by reducing the number of comparisons in each subsequent pass.
 - Consider implementing an early termination if no swaps occur in a pass.