reduce time complexity O(n²) to O(n)
reduce time complexity O(n²) to O(n)

the solution can be optimized by calculating the height in the same recursion  rather than calling a height() function separately.
jaredkoontz/leetcode,jaredkoontz/leetcode,jaredkoontz/leetcode,jaredkoontz/leetcode,jaredkoontz/leetcode