Partitions into distinct parts
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) → intExamples
in
[6]out4What 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
solution.py
InputExpectedGot
[6]4not run yetsample