Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    383 - Ransom Note\.

    Easy

    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.

    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>1 <= ransomNote.length, magazine.length <= 10<sup>5</sup></code>

    • ransomNote and magazine consist of lowercase English letters.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Boolean canConstruct(String ransomNote, String magazine)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait