Back to course home
0% completed
Vote For New Content
Problem 5: Ransom Note (easy)
Problem Statement
Given two strings, one representing a ransom note and the other representing the available letters from a magazine, determine if it's possible to construct the ransom note using only the letters from the magazine. Each letter from the magazine can be used only once.
Examples:
-
Example 1:
- Input: Ransom Note = "hello", Magazine = "hellworld"
- Expected Output: true
- Justification: The word "hello" can be constructed from the letters in "hellworld".
-
Example 2:
- Input: Ransom Note = "notes", Magazine = "stoned"
- Expected Output: true
- Justification: The word "notes" can be fully constructed from "stoned" from its first 5 letters.
-
Example 3:
- Input: Ransom Note = "apple", Magazine = "pale"
- Expected Output: false
- Justification: The word "apple" cannot be constructed from "pale" as we are missing one 'p'.
Constraints:
- 1 <= ransomNote.length, magazine.length <= 10<sup>5</sup>
- ransomNote and magazine consist of lowercase English letters.
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible