Pergunta de entrevista da empresa Pegasystems

Write the C++/Java code to compress the given string it is easy question on the leetcode.