Remove recurring digits in a given number | Java program to remove recurring digits from a given number ; Removes recurring digits in num [ ] ; int j = 0 ; Index in modified string ; Traverse digits of given number one by one ; Copy the first occurrence of new digit ; Remove repeating occurrences of digit ; Driver code
class GFG { static String removeRecurringDigits ( char num [ ] ) { int len = num . length ; String s = " " ; for ( int i = 0 ; i < len ; i ++ ) { s += String . valueOf ( num [ i ] ) ; while ( i + 1 < len && num [ i ] == num [ i + 1 ] ) { i ++ ; } } return s ; } public static void main ( String [ ] args ) { char num [ ] = "1299888833" . toCharArray ( ) ; System . out . print ( " Modified ▁ number ▁ is ▁ " + removeRecurringDigits ( num ) ) ; } }