
I encountered this question a few weeks back on a Codility exam; it was 1/3 questions and was the only question I had a single test case fail. It's been driving me nuts as the algo I used seemed to be straightforward howver this last case kept failing for the following Binary Tree:
1
2
1 1
4
As you can see the max number of distinct nodes is 2 and is the path from root(1)-->right node(2) yet for some reason my code is including 4...despite it traversing the parent node 1.