Code RoomPartitions into distinct parts
HardPrep Room Coding #753

Partitions into distinct parts

CodingDistributed systemsAlgorithms & data structuresSenior–Staff~28 min

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.

0:00 of about 28 min
InputExpectedGot
[6]4not run yetsample