less than 1 minute read

2161. Partition Array According to Given Pivot (medium)

class Solution:
    def pivotArray(self, nums: List[int], pivot: int) -> List[int]:
        less = []
        more = []
        count = 0
        for num in nums:
            if num < pivot:
                less.append(num)
            if num > pivot:
                more.append(num)
            if num == pivot:
                count += 1
        
        return less + [pivot] * count + more