You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: leetcode/medium/912_sort_an_array.md
+38Lines changed: 38 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -71,3 +71,41 @@ class Solution(object):
71
71
quick_sort(0, len(nums)-1)
72
72
return nums
73
73
```
74
+
75
+
## Merge Sort
76
+
77
+
- Runtime: O(Nlog(N))
78
+
- Space: O(N)
79
+
- N = Number of elements in list
80
+
81
+
Merge sort first breaks up the list into elements of one.
82
+
Then from those small elements, merges them together by comparing each left and right list.
83
+
Each left and right list that gets returned is in sorted order, so its a simple two pointer solution to merge the two lists into a larger sorted list. Return this larger sorted list up the recursion and repeat until the entire subset is sorted.
0 commit comments