You are viewing a single comment's thread. Return to all comments →
Corresponding Java Solution, Thanks it was easy to understand :).
static int count=0;
void top_view(Node root){
if(root.left!=null && count>=0){ count++; top_view(root.left); } System.out.print(root.data+ " "); count--; if(root.right!=null && count<0){ count--; top_view(root.right); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Tree : Top View
You are viewing a single comment's thread. Return to all comments →
Corresponding Java Solution, Thanks it was easy to understand :).
static int count=0;
void top_view(Node root){
}