383. Ransom Note Posted on 2021-03-09 In LeetCode Disqus: Symbols count in article: 290 Reading time ≈ 1 mins. O(m+n) time 12345678910111213class Solution {public: bool canConstruct(string ransomNote, string magazine) { int freq[26] = {0}; for (char c : magazine) { ++freq[c - 'a']; } for (char c : ransomNote) { if (--freq[c - 'a'] < 0) return false; } return true; }};