Minimum Deci | Java program to implement the above approach ; Function to find the count of minimum Deci - Binary numbers required to obtain S ; Stores the minimum count ; Iterate over the string s ; Convert the char to its equivalent integer ; If current character is the maximum so far ; Update the maximum digit ; Print the required result ; Driver Code
class GFG { static int minimum_deci_binary_number ( String s ) { int m = Integer . MIN_VALUE ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int temp = s . charAt ( i ) - '0' ; if ( temp > m ) { m = temp ; } } return m ; } public static void main ( String [ ] args ) { String S = "31" ; System . out . println ( minimum_deci_binary_number ( S ) ) ; } }