Google Interview Question

modified lc hard, ood implementation