Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Ransom Note

XPChallenge Points: 10
levelLevel: Easy

You are given two strings, ransomNote and magazine. Your task is to determine whether the characters in ransomNote can be fully formed using the characters available in magazine.

Each character from magazine can be used only one time.
Return true if constructing ransomNote is possible; otherwise, return false.

Example 1:

Input: ransomNote = "abc" magazine = "cba"

Output: true

Explanation:

All letters required for "abc" exist in "cba".

Example 2:

Input: ransomNote = "hello" magazine = "hleolw"

Output: true

Explanation:

The magazine contains all letters needed: h, e, l, l, o.

Example 3:

Input: ransomNote = "aaab" magazine = "aaba"

Output: true

Explanation:

RansomNote needs 3 × 'a', but magazine has only 2 × 'a'.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result