mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
10 lines
293 B
C++
10 lines
293 B
C++
class Solution {
|
|
public:
|
|
bool canConstruct(string ransomNote, string magazine) {
|
|
int bin[26] = { 0 };
|
|
for (const auto& c : magazine) ++bin[c - 'a'];
|
|
for (const auto& c : ransomNote) --bin[c - 'a'];
|
|
return find_if(bin, bin + 26, [](const int& x) {return x < 0; }) == (bin + 26);
|
|
}
|
|
};
|