Frage im Vorstellungsgespräch bei Pegasystems

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