Skip to content

Commit e683058

Browse files
committed
ok
1 parent 81b46d3 commit e683058

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/com/leetcode/Sort.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ public void swap(int[] nums, int posA, int posB) {
1212
/***************************************冒泡排序******************************************
1313
* 平均时间复杂度O(n^2) 空间复杂度O(1) 稳定 最差时间复杂度O(n^2) 最好时间复杂度O(n) */
1414
public void maopaoSort(int[] nums) {
15-
for (int end = nums.length; end > 0; end--) {
16-
for (int i = 0; i < end-1; i++) {
17-
if (nums[i] > nums[i+1])
15+
for (int end = nums.length-1; end > 0; end--) {
16+
for (int i = 0; i < end; i++) {
17+
if (nums[i+1] < nums[i])
1818
swap(nums, i, i+1);
1919
}
2020
}

0 commit comments

Comments
 (0)