Description
Submission
class Solution { int freq[26]; public: bool canConstruct(string ransomNote, string magazine) { for(char ch: magazine) { ++freq[ch-'a']; } for(char ch: ransomNote) { --freq[ch-'a']; } for(int i = 0; i < 26; ++i) { if(freq[i] < 0) return false; } return true; } };