private int maxDepth(TreeNode root){
  if (root == null)   return 0;
  int left=maxDepth(root.left);
  int right=maxDepth(root.right);
  if (left == -1 || right == -1 || Math.abs(left - right) > 1)   return -1;
  return Math.max(left,right) + 1;
}

private int maxDepth ( TreeNode root ) { if ( root == null ) return 0 ; int left = maxDepth ( root . left ) ; int right = maxDepth ( root . right ) ; if ( left == - 1 || right == - 1 || Math . abs ( left - right ) > 1 ) return - 1 ; return Math . max ( left , right ) + 1 ; }
modification of max depth if current node is null , return 0 compare left depth with right depth if the difference is bigger than 1 , set isbalance false otherwise go on to the rest of the nodes
