173. Ransom Note

EasyStringString

Given two strings ransomNote and magazine, return 'true' if ransomNote can be constructed by using letters from magazine, 'false' otherwise.

Each letter in magazine can only be used once.

Input: Two comma-separated strings: ransomNote and magazine.

Output: Return 'true' if the ransom note can be constructed, otherwise 'false'.

Examples

Example 1
Input: a,b
Output: false
Explanation: 'a' not in magazine 'b'.
Example 2
Input: aa,aab
Output: true
Explanation: Magazine has 2 a's, note needs 2 → sufficient.
Example 3
Input: aa,ab
Output: false
Explanation: Magazine has only 1 'a', note needs 2.

Constraints

Asked by

AppleMicrosoftAmazonBloombergGoogleMeta
Solve this problem in the editor →