Code RoomThree-way partition by pivot
EasyPrep Room Coding #143

Three-way partition by pivot

CodingDistributed systemsEntry–Mid~15 min

Given an integer array a and an integer pivot, perform a three-way partition conceptually splitting elements into those less than, equal to, and greater than the pivot. Return a list of three integers: [count_less, count_equal, count_greater]. The array may be empty.

Implement
three_way_partition(a: list[int], pivot: int) → list[int]
Examples
in[[1,4,2,4,2,4,1,3],4]out[5,3,0]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 15 min
InputExpectedGot
[[1,4,2,4,2,4,1,3],4][5,3,0]not run yetsample