https://leetcode.com/problems/balanced-binary-tree



Runtime: 8 ms, faster than 64.31% of Go online submissions for Balanced Binary Tree.
Memory Usage: 5.8 MB, less than 99.63% of Go online submissions for Balanced Binary Tree.



```go
package main

var max_level = 0

func count(node *TreeNode, counting int) {
	if node != nil {
		counting += 1
		if counting > max_level {
			max_level = counting
		}
		count(node.Left, counting)
		count(node.Right, counting)
	}
}

func travel(node *TreeNode) bool {
	if node != nil {
		max_level = 0
		count(node.Left, 0)
		a := max_level

		max_level = 0
		count(node.Right, 0)
		b := max_level

		if (a-b) > 1 || (b-a) > 1 {
			return false
		}

		return travel(node.Left) && travel(node.Right)
	} else {
		return true
	}
}

func isBalanced(root *TreeNode) bool {
	// 7:27
	return travel(root)
	// 7:33
}
```