We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7834c26 commit 9d302a2Copy full SHA for 9d302a2
1 file changed
3.insertionSort.md
@@ -34,4 +34,18 @@ function insertionSort(arr) {
34
}
35
return arr;
36
37
-```
+```
38
+
39
+## 3. Python 代码实现
40
41
+```python
42
+def insertionSort(arr):
43
+ for i in range(len(arr)):
44
+ preIndex = i-1
45
+ current = arr[i]
46
+ while preIndex >= 0 and arr[preIndex] > current:
47
+ arr[preIndex+1] = arr[preIndex]
48
+ preIndex-=1
49
+ arr[preIndex+1] = current
50
+ return arr
51
+'''
0 commit comments