Pregunta de entrevista de ServiceNow

coding question, it was done via hackerrank