Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think the author may have overthought it, but it kind of depends on comfort with recursion and how focused he was when working on the problem.

If you aren't comfortable with recursion, I can see it taking a while.

It's basically a walk down a binary tree with some extra logic. You have to write two recursive functions, one each for (b) and (c) but they have basically the same structure with different return values. The function for (b) can be used for (c) (not the most efficient, but it does work). (d) requires minor modifications to the functions created in (a)-(c) so you can start with copies of the originals and make the change, I think it's a one symbol change in each function, or maybe two.



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: