Bloomberg

Anonymous User
2925
Sep 18, 2022
// The number 1112221111 can be read out as "one, one, one, two, ..." etc: saying each digit from left to right. However, we could be more efficient by grouping like digits. In this case: "three ones, three twos, four ones." This leads to the encoding 313241 (read it out loud!).

// Write a program to encode integers in this way.

// Note: consider the speed of your program: try to avoid expensive string operations.
// 111222. -> 3132

// 3, 1, 3, 2 -->. 3132

O(1) space
Any ideas?
Comments (7)