Bug fixes and improvements (#1133)

* Bug fixes

* Update the figure of the JD link

* Unify the code comments of insertion_sort
This commit is contained in:
Yudong Jin
2024-03-14 20:01:16 +08:00
committed by GitHub
parent eadf4c86d4
commit 01c67781fa
14 changed files with 23 additions and 23 deletions

View File

@@ -6,11 +6,11 @@
/* */
func insertionSort(nums: inout [Int]) {
// 1, 2, ..., n
// [0, i-1]
for i in stride(from: 1, to: nums.count, by: 1) {
let base = nums[i]
var j = i - 1
// base
// base [0, i-1]
while j >= 0, nums[j] > base {
nums[j + 1] = nums[j] // nums[j]
j -= 1