Pergunta de entrevista da empresa Uncountable

Some string manipulation problem. Probably leetcode easy or medium