public boolean hasPathSum(TreeNode root, int sum) {
    	if(root == null) return false;
    	boolean bleft = false, bright=false;
    	
    	if(root.left==null && root.right==null) 
    	{
    		if(sum==root.val) 
    			return true;
    		else
    			return false;
    	}
    	
    	if(root.left != null) bleft =hasPathSum(root.left, sum-root.val);
    	if(root.right != null) bright =hasPathSum(root.right, sum-root.val);
        return  bleft||bright;
    }