Check if an encoding represents a unique binary string | C # program to check if given encoding represents a single string . ; Return true if sum becomes k ; Driver Code
using System ; class GFG { static bool isUnique ( int [ ] a , int n , int k ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += a [ i ] ; sum += n - 1 ; return ( sum == k ) ; } static public void Main ( ) { int [ ] a = { 3 , 3 , 3 } ; int n = a . Length ; int k = 12 ; if ( isUnique ( a , n , k ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }