Pregunta de entrevista de Applied Materials

A leetcode medium question in the take home assessment