mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 383.cpp
This commit is contained in:
parent
52f610aeae
commit
ec159367b3
9
LeetCode-CN/383.cpp
Normal file
9
LeetCode-CN/383.cpp
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user