Optiver interview question

Binary Tree of Errors Hackerank Problem