383. Ransom Note
Question
Given two strings
ransomNoteandmagazine, returntrue* ifransomNotecan be constructed by using the letters frommagazineandfalseotherwise*.Each letter in
magazinecan only be used once inransomNote.
Solution
数组统计,统计magazine内的字符。
遍历ransomNote,如果对字符数组位置为0则返回false。
每次遍历减少数组统计结果。
最后返回true。
Code
1 | class Solution { |
383. Ransom Note
