Ransom Note Problem
Ransom Note Problem — ExecCode School DSA Practice
Solve the Ransom Note problem on ExecCode. Free online school DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine, and false otherwise. Each letter in magazine can only be used once in ransomNote.
Examples
Input ransomNote = "aaabbb", magazine = "aabbbccc"; Output false. Input ransomNote = "a", magazine = "b"; Output false. Input ransomNote = "aa", magazine = "aab"; Output true
Constraints
1 ≤ ransomNote.length, magazine.length ≤ 10⁵ ransomNote and magazine consist of lowercase English letters
Practice Ransom Note free on ExecCode. Browse DSA problems, topic map, and placement guides.