Pregunta de entrevista de IMC Trading

Basic DP question involving substrings