If weighted String of the current node contains unique characters
if ( uniqueChars ( weight [ node ] . ToCharArray ( ) ) ) cnt += 1 ; foreach ( int to in graph [ node ] ) { if ( to == parent ) continue ; dfs ( to , node ) ; } }