Remove one bit from a binary number to get maximum value | Function to find the maximum binary number ; Traverse the binary number ; Try finding a 0 and skip it ; Get the binary number ; Find the maximum binary number
< ? php function printMaxAfterRemoval ( $ s ) { $ flag = false ; $ n = strlen ( $ s ) ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { if ( $ s [ $ i ] == '0' && $ flag == false ) { $ flag = true ; continue ; } else echo $ s [ $ i ] ; } } $ s = "1001" ; printMaxAfterRemoval ( $ s ) ; ? >