MCPcopy Create free account
hub / github.com/BeeBombshell/Python-DSA / Solution

Class Solution

Sort-all/quick.py:1–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Solution:
2 def sortArray(self, N: List[int]) -> List[int]:
3 def quicksort(A, I, J):
4 if J - I <= 1: return
5 p = partition(A, I, J)
6 quicksort(A, I, p), quicksort(A, p + 1, J)
7
8 def partition(A, I, J):
9 A[J-1], A[(I + J - 1)//2], i = A[(I + J - 1)//2], A[J-1], I
10 for j in range(I,J):
11 if A[j] < A[J-1]: A[i], A[j], i = A[j], A[i], i + 1
12 A[J-1], A[i] = A[i], A[J-1]
13 return i
14
15 quicksort(N,0,len(N))
16 return N
17
18

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected