Google Interview Question

a monotoious related medium coding problem