Package g0301_0400.s0383_ransom_note
Class Solution
-
- All Implemented Interfaces:
public final class Solution
383 - Ransom Note\.
Easy
Given two strings
ransomNote
andmagazine
, returntrue
ifransomNote
can be constructed by using the letters frommagazine
andfalse
otherwise.Each letter in
magazine
can only be used once inransomNote
.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
andmagazine
consist of lowercase English letters.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final Boolean
canConstruct(String ransomNote, String magazine)
-
-
Method Detail
-
canConstruct
final Boolean canConstruct(String ransomNote, String magazine)
-
-
-
-