Code Room
CodingEasycod-g086
Subject Dutch flagLevel Entry–Mid~15 minCommon in Distributed systems interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.