human
Write me a code to check whether second string can be formed from characters of first string used any number of times and the other steps required given the following:
Check whether second string can be formed from characters of first string used any number of times | Function to check if str2 can be made by characters of str1 or not.
To store the occurrence of every character.
Length of the two strings.
Assume that it is possible to compose the string str2 from str1.
Iterate over str1.
Store the presence or every element.
Iterate over str2.
Ignore the spaces.
Check for the presence of character in str1.
If it is possible to make str2 from str1.
Given strings.
Function call ."
Solution in Python:
assistant
#Here is code to check whether second string can be formed from characters of first string used any number of times and the other steps required.
 def isPossible ( str1 , str2 ) :
	arr = { }
	l1 = len ( str1 )
	l2 = len ( str2 )
	possible = True
	for i in range ( l1 ) :
		arr [ str1 [ i ] ] = 1
	for i in range ( l2 ) :
		if str2 [ i ] != ' ▁ ' :
			if arr [ str2 [ i ] ] == 1 :
				continue
			else :
				possible = False
				break
	if possible :
		print ( " Yes " )
	else :
		print ( " No " )
str1 = " we ▁ all ▁ love ▁ geeksforgeeks "
str2 = " we ▁ all ▁ love ▁ geeks "
isPossible ( str1 , str2 )