Repeatedly Add Consecutive Equal Digits
See the Image Source section at the very bottom of the page for the original problem statement ๐ผ
Imagine you're given a string made entirely of digits, and your goal is to transform it by repeatedly applying a special operation whenever there are consecutive identical digits. Here's how it works: if a number has repeated digits, you replace each group of consecutive digits with their sum. For example, the number "999433" would become "2746" because 9 + 9 + 9 equals 27, and 3 + 3 equals 6. You keep doing this until there are no consecutive digits left. For instance, "44488366664" would first transform to "12163244." Keep applying this process until the string no longer has any repeating digits, and that's your final result. The challenge here is to find an approach that gets this done efficiently, though it doesn't need to be the most optimal one.
๐ฐ Appreciation to Charlotte baby ๐ฐ
1Example 1
2Example 2
3Example 3
4Example 4
number = "08166". Then it sequentially becomes 08112
P.S. The explanation isn't complete. I'll add more once I find more reliable source :)Constraints
Limits and guarantees your solution can rely on.