human
Count strings from given array having all characters appearing in a given string | Function to count the number of strings from an array having all characters appearing in the string S.
Initialize a set to store all distinct characters of S.
Traverse over S.
Insert characters into the Set.
Stores the required count.
Traverse the array.
Traverse over arr [ i ].
Check if character in arr [ i ] [ j ] is present in the S or not.
Increment the count if all the characters of arr [ i ] are present in the S.
Finally , prthe count.
Driver code"
Solution in Python:
assistant
#Here is code to count strings from given array having all characters appearing in a given string and the other steps required.
 def countStrings ( S , list ) :
	valid = { }
	for x in S :
		valid [ x ] = 1
	cnt = 0
	for i in range ( len ( list ) ) :
		j = 0
		while j < len ( list [ i ] ) :
			if ( list [ i ] [ j ] in valid ) :
				j += 1
				continue
			else :
				break
			j += 1
		if ( j == len ( list [ i ] ) ) :
			cnt += 1
	return cnt
if __name__ == ' _ _ main _ _ ' :
	arr = [ " ab " , " aab " , " abaaaa " , " bbd " ]
	S , l = " ab " , [ ]
	print ( countStrings ( S , arr ) )