solution for problem balanced binary tree