Check if an encoding represents a unique binary string | PHP program to check if given encoding represents a single string ; Return true if sum becomes k ; Driver Code
< ? php function isUnique ( $ a , $ n , $ k ) { $ sum = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ sum += $ a [ $ i ] ; $ sum += $ n - 1 ; return ( $ sum == $ k ) ; } $ a = array ( 3 , 3 , 3 ) ; $ n = count ( $ a ) ; $ k = 12 ; if ( isUnique ( $ a , $ n , $ k ) ) echo " Yes " ; else echo " No " ; ? >