LeetCode-Solutions-in-Cpp17

Solutions to high-frequency interview questions of LeetCode in C++17, taking into account both efficiency and comprehensibility.


Project maintained by downdemo Hosted on GitHub Pages — Theme by mattgraham
class Solution {
 public:
  bool isAnagram(string s, string t) {
    vector<int> v(26);
    for (auto& x : s) {
      ++v[x - 'a'];
    }
    for (auto& x : t) {
      --v[x - 'a'];
    }
    return all_of(begin(v), end(v), [](int x) { return !x; });
  }
};