Sum of twos and threes
Count the ordered ways to write a non-negative integer n as a sum of parts where every part is 2 or 3. Order matters: 2+3 and 3+2 are different. Return the count; return 1 for n = 0 (the empty sum) and 0 when no such sum exists (for example n = 1). For example, n = 5 has two ways (2+3 and 3+2), and n = 7 has three (2+2+3, 2+3+2, 3+2+2).
Implement
count_two_three_sums(n: int) → intExamples
in
[5]out2in
[7]out3What 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 12 min
solution.py
InputExpectedGot
[5]2not run yetsample[7]3not run yetsample