Code Room
CodingHardcod-g179
Subject Combinatorial countingLevel Senior–Staff~28 minCommon in Distributed systems · Algorithms & data structures interviewsIndustries Software development

Question

Given a non-negative integer n (0 <= n <= 60), return the number of ways to write n as a sum of DISTINCT positive integers, where order does not matter. For example n = 6 has 4 such partitions: 6; 1+5; 2+4; 1+2+3. By convention n = 0 has exactly one partition (the empty sum).

Implement
count_partitions_distinct(n: int) → int
Examples
in[6]out4
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.