Closed Karthiks08 closed 3 years ago
/**
} */
class Solution { public List rightSideView(TreeNode root) { List result=new ArrayList<>();
if(root==null){ return result; } Queue<TreeNode> q=new LinkedList<>(); q.add(root); while(q.size()>0){ int count=q.size(); while(count-->0){ TreeNode val=q.remove(); if(count==0){ result.add(val.val); } if(val.left!=null){ q.add(val.left); } if(val.right!=null){ q.add(val.right); } } } return result;
} }
this is my code
This is not the right way to submit a PR Follow the steps properly and then submit the request !!
/**
} */
class Solution { public List rightSideView(TreeNode root) {
List result=new ArrayList<>();
} }