Peeush Agarwal > Engineer. Learner. Builder.

I am a Machine Learning Engineer passionate about creating practical AI solutions using Machine Learning, NLP, Computer Vision, and Azure technologies. This space is where I document my projects, experiments, and insights as I grow in the world of data science.

View on GitHub

Ransom Note

Problem Statement

Given two strings ransomNote and magazine, determine if ransomNote can be constructed using the letters from magazine. Each letter in magazine can only be used once in constructing ransomNote.

Examples

Example 1
Input: ransomNote = "a", magazine = "b"
Output: false

Example 2
Input: ransomNote = "aa", magazine = "ab"
Output: false

Example 3
Input: ransomNote = "aa", magazine = "aab"
Output: true

Constraints

Code Template

class Solution:
    def canConstruct(self, ransomNote: str, magazine: str) -> bool:
        # Your code here
        pass

Solutions

Back to Problem List Back to Categories