class Same {
  public:
    bool checkSam(string stringA, string stringB) {
        // write code here
        array<int, 128> bufA{ 0 };  // 保存字符串a的遍历值
        array<int, 128> bufB{ 0 };  // 保存字符串b的遍历值
        for (auto& ch : stringA) {
            bufA[ch] += 1;
        }
        for (auto& ch : stringB) {
            bufB[ch] += 1;
        }
        for (int i = 0; i < 128; i++) {
            if (bufA[i] != bufB[i]) {
                return false;
            }
        }
        return true;
    }
};

使用两个数组来保存每个字符串遍历后的值,最后比对两个字符串的值