MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / lexicalOrder

Method lexicalOrder

LexicographicalNumbers.java:3–10  ·  view source on GitHub ↗
(int n)

Source from the content-addressed store, hash-verified

1//DFS
2class Solution {
3 public List<Integer> lexicalOrder(int n) {
4 List<Integer> res = new ArrayList<>();
5 for(int i=1;i<10;i++){
6 if(i>n) break;
7 dfs(i,n,res);
8 }
9 return res;
10 }
11 public void dfs(int curNum, int target, List<Integer>res){
12 if(curNum>target){
13 return;

Callers

nothing calls this directly

Calls 2

dfsMethod · 0.95
addMethod · 0.45

Tested by

no test coverage detected