Bubble Sort
unknown
java
10 months ago
436 B
6
Indexable
class Solution {
public int bubbleSort(int[] nums) {
int i, j, n = nums.length, temp;
for(i=0;i<n;++i)
{
for(j=i+1;j<n;++j)
{
if(nums[i]>nums[j])
{
temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
}
}
return nums;
}
}
Editor is loading...
Leave a Comment