A String Problem

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

You are given 2 sentences, A, and B containing lowercase letters, and spaces. You have to check if it is possible to reconstruct the first string using only characters in the second string, including spaces.

Input Specification

The first line will contain the string A\ (1 \le |A| \le 10^5).

The second line will contain the string B\ (1 \le |B| \le 10^5).

Note that it is not guaranteed there is only one space between any two letters, nor that the strings will not contain trailing/leading spaces.

Output Specification

Output YES if it is possible to make sentence A using only characters from sentence B, and NO otherwise.

Sample Input 1

  aapo
aosa   p

Sample Output 1

YES

Sample Input 2

aopsk  
oapsk

Sample Output 2

NO

Explanation for Sample 2

There are trailing spaces in sentence A that are not in sentence B.

Sample Input 3

aa
a

Sample Output 3

NO

Comments

There are no comments at the moment.