How to think it in the DFS way


  • 2
    W

    0_1480987480523_upload-12fc3406-aae6-484c-a653-1fa91e5f2ec5

    we can imagine such a tree, out task is to traversal it with DFS, and collect numbers along the way: 1, 10, 100, ... you get it. When we encounter a number larger than n, we can return back to the previous level.

    Hope it helps


  • 0
    D

    very helpful!!


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.