text: Replace ' ? ' to convert given string to a binary string with maximum count of '0' and "10" | C ++ program to implement the above approach ; Function to maximize count of 0 and 10 by replacing character ' ? ' to '0' or '1' ; Traverse the given string ; If current character is ' ? ' ; Replace str [ i ] to '0' ; Driver Code ; Given string
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; void findMaxOccurence ( string str , int N ) { for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == ' ? ' ) { str [ i ] = '0' ; } } cout << str << endl ; } int main ( ) { string str = "10?0?11" ; int N = str . length ( ) ; findMaxOccurence ( str , N ) ; return 0 ; }