Remove one bit from a binary number to get maximum value | C # program to find next maximum binary number with one bit removed ; Function to find the maximum binary number ; Traverse the binary number ; Try finding a 0 and skip it ; Driver Code ; Get the binary number ; Find the maximum binary number
using System ; class GFG { static int printMaxAfterRemoval ( String s ) { bool flag = false ; int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '0' && flag == false ) { flag = true ; continue ; } else Console . Write ( s [ i ] ) ; } return 0 ; } static void Main ( ) { String s = "1001" ; printMaxAfterRemoval ( s ) ; } }