# [383\. Ransom Note](https://leetcode.com/problems/ransom-note/) :::spoiler Solution ```cpp class Solution { public: bool canConstruct(string ransomNote, string magazine) { vector<int> freq(26); for(auto& c : magazine) ++freq[ c - 'a']; for(int i = 0; i < ransomNote.size(); i++) { int c = ransomNote[i] - 'a'; if (--freq[c] < 0) return false; } return true; } }; ``` - T: $O(N)$ - S: $O(1)$ :::