Skip to content
Decoder

Ransom Note

Easy

Problem

You want to spell ransom_note using letters cut out of magazine. **Each letter in magazine can be used only once.** Return true if it can be done.

Example 1

Input
ransom_note = "a", magazine = "b"
Output
false

Example 2

Input
ransom_note = "aa", magazine = "ab"
Output
false
Why
only one a

Example 3

Input
ransom_note = "aa", magazine = "aab"
Output
true

Constraints

  • 0 <= ransom_note.length, magazine.length <= 10^5
  • Both strings contain only lowercase English letters.

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.