思路:DFS遍历字典树
class Solution:# 维护了一个隐性的字典树,只要对其进行dfs即可def lexicalOrder(self, n: int) -> List[int]:recVal = list()def dfs(curVal: int, curDepth: int) -> None:if curVal > n or (curVal == 0 and curDepth != 0):returnif curDepth > 0:recVal.append(curVal)for i in range(10):dfs(curVal * 10 + i, curDepth + 1)dfs(0, 0)return recVal

