public class Solution {
public boolean isBalanced(TreeNode root)
{
if(root==null)return true;
int maxHeight=getHeight(root,true);
System.out.println(maxHeight);
int minHeight=getHeight(root,false);
System.out.println(minHeight);
return Math.abs(maxHeightminHeight)<=1?true:false;
}
public int getHeight(TreeNode root,boolean flag)
{
if(root==null) return 0;
if(flag==true) return (Math.max(getHeight(root.left,true)+1,getHeight(root.right,true)+1));
else
return (Math.min(getHeight(root.left,false)+1,getHeight(root.right,false)+1));
}
}
What is wrong in my code


Check this link you will get answer
https://leetcode.com/discuss/59/differentdefinitionsbalancedresultdifferentjudgments