human
Give me a code to print all Strings from array A [ ] having all strings from array B [ ] as subsequence and the other steps required given the following:
Print all Strings from array A [ ] having all strings from array B [ ] as subsequence | Function to find strings from A [ ] having all strings in B [ ] as subsequence.
Calculate respective sizes.
Stores the answer.
Stores the frequency of each character in strings of A [ ].
Compute the frequencies of characters of all strings.
Stores the frequency of each character in strings of B [ ] each character of a string in B [ ].
If the frequency of a character in B [ ] exceeds that in A [ ].
A string exists in B [ ] which is not a proper subset of A [ i ].
If all strings in B [ ] are proper subset of A [ ].
Push the string in resultant vector.
If any string is found.
Print those strings.
Otherwise.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to print all Strings from array A [ ] having all strings from array B [ ] as subsequence and the other steps required.
 def UniversalSubset ( A , B ) :
	n1 = len ( A )
	n2 = len ( B )
	res = [ ]
	A_freq = [ [ 0 for x in range ( 26 ) ] for y in range ( n1 ) ]
	for i in range ( n1 ) :
		for j in range ( len ( A [ i ] ) ) :
			A_freq [ i ] [ ord ( A [ i ] [ j ] ) - ord ( ' a ' ) ] += 1
	B_freq = [ 0 ] * 26
	for i in range ( n2 ) :
		arr = [ 0 ] * 26
		for j in range ( len ( B [ i ] ) ) :
			arr [ ord ( B [ i ] [ j ] ) - ord ( ' a ' ) ] += 1
			B_freq [ ord ( B [ i ] [ j ] ) - ord ( ' a ' ) ] = max ( B_freq [ ord ( B [ i ] [ j ] ) - ord ( ' a ' ) ] , arr [ ord ( B [ i ] [ j ] ) - ord ( ' a ' ) ] )
	for i in range ( n1 ) :
		flag = 0
		for j in range ( 26 ) :
			if ( A_freq [ i ] [ j ] < B_freq [ j ] ) :
				flag = 1
				break
		if ( flag == 0 ) :
			res . append ( A [ i ] )
	if ( len ( res ) ) :
		for i in range ( len ( res ) ) :
			for j in range ( len ( res [ i ] ) ) :
				print ( res [ i ] [ j ] , end = " " )
	else :
		print ( - 1 , end = " " )
if __name__ == ' _ _ main _ _ ' :
	A = [ " geeksforgeeks " , " topcoder " , " leetcode " ]
	B = [ " geek " , " ee " ]
	UniversalSubset ( A , B )