[LeetCode] Additive Number

  • 时间:
  • 浏览:0

If you are a Pythoner, you may also love Stefan's code, which is pasted below.

This problem can also be solved iteratively, like peisi's code, which is rewritten in C++ below.

Af first I read the title as "Addictive Number". Anyway, this problem can be solved elegantly using recursion. This post shares a nice recursive C++ code with handling of the follow-up by implementing string addition function.

The code is rewritten as follows.