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 :)
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 RUclips TechDose 386 for(int i=0;i n){ return ; } dfsHelper(next,n,ans); }
Perfect ! to the point thanks for the code walk through and the recursion tree
welcome :)
Perfectly expanded
Thanks :)
excellant ek bar dekh ke smjh aa gaya
Great
Really great explanation !
Glad you liked it!
Perfect i understand thank u sir
Great
Recursion will take stack space, this isn't an O(1) solution
1. You can convert the logic to iterative code.
2. The depth is only max 5 hence can be taken constant.
@@techdose4u True got it
really good video
Thanks
depth will change acc. to number.
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 :)
please provide java code as well.
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 RUclips TechDose 386
for(int i=0;i n){
return ;
}
dfsHelper(next,n,ans);
}
}
}
Thanks :)