Remove recurring digits in a given number | C ++ program to remove recurring digits from a given number ; Removes recurring digits in num [ ] ; Traverse digits of given number one by one ; Copy the first occurrence of new digit ; Remove repeating occurrences of digit ; Driver program to test above function
#include <bits/stdc++.h> NEW_LINE using namespace std ; void removeRecurringDigits ( char num [ ] ) { int len = strlen ( num ) ; for ( int i = 0 ; i < len ; i ++ ) { num [ j ++ ] = num [ i ] ; while ( i + 1 < len && num [ i ] == num [ i + 1 ] ) i ++ ; } int main ( ) { char num [ ] = "1299888833" ; removeRecurringDigits ( num ) ; cout << " Modified ▁ number ▁ is ▁ " << num ; return 0 ; }