Skip to content

Commit 47702f7

Browse files
committed
912
1 parent 5dc17a7 commit 47702f7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Sort/912.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Sort an Array
2+
3+
#### Description
4+
5+
[link](https://leetcode.com/problems/sort-an-array/)
6+
7+
---
8+
9+
#### Solution
10+
11+
- See Code
12+
13+
---
14+
15+
#### Code
16+
17+
O(nlog(n))
18+
19+
```python
20+
class Solution:
21+
def sortArray(self, nums: List[int]) -> List[int]:
22+
if not nums or len(nums) == 1:
23+
return nums
24+
a = nums[0]
25+
small = [n for n in nums[1:] if n <= a]
26+
large = [n for n in nums[1:] if n > a]
27+
return self.sortArray(small) + [a] + self.sortArray(large)
28+
```

0 commit comments

Comments
 (0)