Google Interview Question

Technical coding question with decent difficulty