Amazon Interview Question

The toughest question was to solve H-Tree