Ad
  • Custom User Avatar

    Does negative numbers matter ?

    is a way of writing n as a sum of positive integers

    No.

    Should I count 0 as a way to sum ?

    No. A positive number is a number greater than 0.

    Are 2 + 1 and 1 + 2 considered 1 possiblity ?

    For example, 4 can be partitioned in five distinct ways:

    4
    3 + 1
    2 + 2
    2 + 1 + 1
    1 + 1 + 1 + 1
    

    If it says there are 5 partitions and you don't see 1 + 3 or 1 + 2 + 1 the answer is obviously yes.

  • Custom User Avatar

    Read the description and the examples.

  • Custom User Avatar

    Yeah, I just managed to solve it in 103 ms, but got ~300 with the naive approach. Read over the question again - maybe there's a piece of information you're not using? ;)