Google Interview Question

Asked me DSA question of medium difficulty