Google Interview Question

It was a leet code problem