Perfect ! to the point thanks for the code walk through and the recursion tree
@techdose4u2 ай бұрын
welcome :)
@JiyaRana-w7m2 ай бұрын
Perfect i understand thank u sir
@techdose4u2 ай бұрын
Great
@AnuragKumar-jo4li2 ай бұрын
really good video
@techdose4u2 ай бұрын
Thanks
@PreyumKumar2 ай бұрын
depth will change acc. to number.
@techdose4u2 ай бұрын
depth will change in LogBase10 order. Since, problem mentions constraints to be very low hence we can ignore Call stack. Else, you can convert this logic to iterative approach :)
@rishabh._.raj12 ай бұрын
Recursion will take stack space, this isn't an O(1) solution
@techdose4u2 ай бұрын
1. You can convert the logic to iterative code. 2. The depth is only max 5 hence can be taken constant.
@rishabh._.raj12 ай бұрын
@@techdose4u True got it
@nikhilaggarwal93252 ай бұрын
please provide java code as well.
@Sehnaaz-vf7md2 ай бұрын
The Java solution: class Solution { public List lexicalOrder(int n) { List ans= new ArrayList(); for(int i =1; in){ return; } ans.add(Current); //Generate the next number to add and check whether it exceeds the limit 'n' //remember the recursive tree while coding refer KZbin TechDose 386 for(int i=0;i n){ return ; } dfsHelper(next,n,ans); } } }