![]() |
VOOZH | about |
Given an integer, remove consecutive repeated digits from it.
Examples:
Input: x = 12224 Output: 124 Input: x = 124422 Output: 1242 Input: x = 11332 Output: 132
We need to process all digits of n and remove consecutive representations. We can go through all digits by repeatedly dividing n with 10 and taking n%10.
124
Time Complexity: O(log10n)
Auxiliary Space: O(1)