**Solution**

**Lexicographical Numbers** https://leetcode.com/problems/lexicographical-numbers/

- The key insight in this question is to model this as a graph and apply DFS.
- Draw the recursion and implement the code.
- https://goo.gl/photos/7XTcssvrdXvXhUDi8

```
class Solution(object):
def helper(self, curr, result, n):
result.append(curr)
start = 1 if curr == 0 else 0
for i in range(start, 10):
if curr * 10 + i <= n:
self.helper(curr*10 + i, result, n)
return
def lexicalOrder(self, n):
"""
:type n: int
:rtype: List[int]
"""
result = []
self.helper(0, result, n)
return result[1:]
```