Encode and Rebuild a Binary Tree | Apple Interview Question