Ad
  • Custom User Avatar

    Можно, но временыые затраты на выполнение кода значительно выше.

  • Custom User Avatar

    It might be a nice modification to this question to ask for the value on the nth day, then have a test that runs out of memory if you keep all of both lists in memory.

  • Custom User Avatar

    You don't need recursion.

  • Custom User Avatar

    I did this in Python and first tried to avoid defining new functions and do it recursively, but even if my code completed the sample tests I couldn´t pass when attempting the full tests. My question is if this could have been completed recursively, since I couldn´t find a way to avoid recalculating every day for john and ann in each recursion which obviously made my code time out when attempting the full set of tests.