String window question(Not able to understand)

Do I need to take space also in consideration while checking for occurances of characters of string2 in string1?

Yes. It’s clearly mentioned in the question that both string 1 and string 2 may contain spaces.