Pregunta de entrevista de Medtronic

Python coding problem to implement a a function that solves the proposed problem