Ad
  • Custom User Avatar

    Note on recursion is IMO not necessary. I think it's your task to know when recursion is a good tool, and when it's not. If you decide to use it, you should already know (or find out) if it's applicable to your problem, in your language, etc.

    Recursion, just like every other tool, has its advantages and disadvantages. Here, the latter outweigh the former. You just picked the wrong tool for the job.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    So, can we somehow mark this solution as "NOT OK" so not to confuse anyone?