if difference between parent and child is equal to 1 then do continue otherwise make flag = 0 and break
if ( abs ( temp -> right -> val - temp -> val ) == 1 ) Q . push ( temp -> right ) ; else { flag = 0 ; break ; } } } if ( flag ) return true ; else return false ; }