Pregunta de entrevista de National General Insurance

A leetcode problem, easy difficulty.