Serialize and deserialize a binary tree | Amazon Interview Question