Is_Balanced(Binary Tree)

My 1 test case is not passed.

import java.util.*;
public class Main3 {

static Scanner scn = new Scanner(System.in);

public static void main(String[] args) {
	Main3 m = new Main3();
	BinaryTree bt = m.new BinaryTree();
	System.out.println(bt.isBalanced());
}

private class BinaryTree {
	private class Node {
		int data;
		Node left;
		Node right;
	}

	private Node root;
	private int size;

	public BinaryTree() {
		this.root = this.takeInput(null, false);
	}

	public Node takeInput(Node parent, boolean ilc) {

		int cdata = scn.nextInt();
		Node child = new Node();
		child.data = cdata;
		this.size++;

		// left
		boolean hlc = scn.nextBoolean();

		if (hlc) {
			child.left = this.takeInput(child, true);
		}

		// right
		boolean hrc = scn.nextBoolean();

		if (hrc) {
			child.right = this.takeInput(child, false);
		}

		// return
		return child;
	}

	public boolean isBalanced() {
		return this.isBalanced(this.root).isBalanced;
	}

	private BalancedPair isBalanced(Node node) {
        if(node==null){
            BalancedPair bp = new BalancedPair();
            bp.height=-1;
            bp.isBalanced=true;
            return bp;
        }
        BalancedPair lp=isBalanced(node.left);
        BalancedPair rp=isBalanced(node.right);
        BalancedPair bp = new BalancedPair();
        bp.height=Math.max(lp.height, rp.height)+1;

        if(Math.abs(lp.height - rp.height) > 1 && !lp.isBalanced && !rp.isBalanced ){
            bp.isBalanced=false;
        }else{
            bp.isBalanced=true;
        }
        return bp;
        }

	private class BalancedPair {
		int height;
		boolean isBalanced;
	}

}

}

Change && to || in the Math.abs() condition.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.