leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
2840.cpp (488B)
0 class Solution {
1 public:
2 bool checkStrings(const string &s1, const string &s2) const {
3 int count1[27] = {0}, count2[27] = {0};
5 for (int i = 0; i < size(s1); i += 2) {
6 count1[s1[i] & 0x1F]++;
7 count1[s2[i] & 0x1F]--;
8 count2[s1[i + 1] & 0x1F]++;
9 count2[s2[i + 1] & 0x1F]--;
10 }
12 for (int i = 1; i <= 26; i++) {
13 if (count1[i] || count2[i]) return false;
14 }
16 return true;
17 }
18 };