leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2840.cpp (488B)


      1 class Solution {
      2   public:
      3     bool checkStrings(const string &s1, const string &s2) const {
      4         int count1[27] = {0}, count2[27] = {0};
      5 
      6         for (int i = 0; i < size(s1); i += 2) {
      7             count1[s1[i] & 0x1F]++;
      8             count1[s2[i] & 0x1F]--;
      9             count2[s1[i + 1] & 0x1F]++;
     10             count2[s2[i + 1] & 0x1F]--;
     11         }
     12 
     13         for (int i = 1; i <= 26; i++) {
     14             if (count1[i] || count2[i]) return false;
     15         }
     16 
     17         return true;
     18     }
     19 };