Pregunta de entrevista de Anduril

One Leetcode medium problem and a follow up.