This function calculates number of unique characters using a associative array count [ ] . Returns true if no . of characters are less than required else returns false .
bool isValid ( int count [ ] , int k ) { int val = 0 ; for ( int i = 0 ; i < MAX_CHARS ; i ++ ) if ( count [ i ] > 0 ) val ++ ;