In question it is given that it contains spaces also

Then I have to check spaces also???

Hi @rishravi937, yes you’re supposed to check spaces also.
So if s2 has 5 a’s 3 b’s and 2 spaces you should find a substring in s1 that has atleast 5 a’s atleast 3 b’s and atleast 2 spaces.