Why we have to do dfs?

Tags: #<Tag:0x00007f2425c47020>


since we are checking an integer so at max it can be 10^9 which would require only a vector of length 10 which is constant space so we just need to check numbers from range n to m by converting them to vectors of digit and checking whether they satisfy or not.
Complexity: O((m-n+1)*10) which is equivalent to O(n) so why will I choose dfs.