VOOZH about

URL: https://www.geeksforgeeks.org/dsa/remove-repeated-digits-in-a-given-number/

⇱ Remove repeated digits in a given number - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Remove repeated digits in a given number

Last Updated : 27 Jun, 2022

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. 


Output
124

Time Complexity: O(log10n)
Auxiliary Space: O(1)

Comment