Pregunta de entrevista de Capital One

Standard leetcode questions easy-medium difficulty.