Pergunta de entrevista da empresa RMS

Walk me through your though process to implement this logic