/* function TreeNode(x) {
this.val = x;
this.left = null;
this.right = null;
} */
function IsBalanced_Solution(pRoot)
{
// write code here
function getDepth(root){
if(root === null) return 0
let left = getDepth(root.left)
if(left === -1) return -1
let right = getDepth(root.right)
if(right === -1) return -1
return Math.abs(left-right)>1 ? -1 : 1+Math.max(left,right)
}
let L = getDepth(pRoot)
if(L!== -1){
return true
}else{
return false
}
}
module.exports = {
IsBalanced_Solution : IsBalanced_Solution
};