Python data engineering interview problem. Difficulty: beginner. Pattern: Two Pointers. About 10 minutes. Part of the Pro drill bank.
All unique triplets that sum to zero, sorted. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
Implement three_sum(nums: list) -> list returning unique triplets that sum to 0. Each triplet sorted ascending; outer list sorted.
Input: three_sum([-1, 0, 1, 2, -1, -4]) Output: [[-1, -1, 2], [-1, 0, 1]] Two distinct triplets.
Topics: lakebench, python, triplets, sorted.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: All unique triplets that sum to zero, sorted.
Implement `three_sum(nums: list) -> list` returning unique triplets that sum to 0. Each triplet sorted ascending; outer list sorted. Example: `[-1, 0, 1, 2, -1, -4]` → `[[-1, -1, 2], [-1, 0, 1]]`. Keep the harness.