Google DeepMind Interview Question

Medium difficulty array coding question