We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6539f79 commit d8d70aeCopy full SHA for d8d70ae
1 file changed
Binary Tree/TopViewOfBTUsingDFS.java
@@ -58,7 +58,8 @@ static void dfs(Node root, Map<Integer, int[]> map, int hd, int level){
58
return;
59
}
60
61
- if(!map.containsKey(hd) || map.get(hd)[1] > level){
+ if(!map.containsKey(hd) || map.get(hd)[1] > level){ // we are checking the level value at the same hd in the map.
62
+ //if the level value we are processing is smaller than the one already in map, we will put in the map
63
map.put(hd, new int[]{root.val, l});
64
65
0 commit comments