Pregunta de entrevista de RMS

Walk me through your though process to implement this logic