Skip to content

Instantly share code, notes, and snippets.

@YK-Unit
Created September 8, 2023 22:13
Show Gist options
  • Save YK-Unit/47e95f40cd338db5a56c4328a1be56ad to your computer and use it in GitHub Desktop.
Save YK-Unit/47e95f40cd338db5a56c4328a1be56ad to your computer and use it in GitHub Desktop.
<以下是使用 Python 实现快速排序的代码: ```python def quick_sort(arr): if len(arr) <= 1: return arr else: pivot = arr[0] left = [x for x in arr[1:] if x < pivot] right = [x for x in arr[1:] if x >= pivot] return quick_sort(left) + [pivot] + quick_sort(right) ```>
<以下是使用 Python 实现快速排序的代码:
```python
def quick_sort(arr):
if len(arr) <= 1:
return arr
else:
pivot = arr[0]
left = [x for x in arr[1:] if x < pivot]
right = [x for x in arr[1:] if x >= pivot]
return quick_sort(left) + [pivot] + quick_sort(right)
```>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment