面试题 01.02. 判定是否互为字符重排 Posted on 2021-07-19 Edited on 2022-11-27 In leetcode Disqus: Symbols count in article: 294 Reading time ≈ 1 mins. 面试题 01.02. 判定是否互为字符重排 3次遍历O(3n) 1234567891011121314class Solution {public: bool CheckPermutation(string s1, string s2) { int a[26]{ 0 }; for(auto& ch : s1) a[ch - 'a'] += 1; for(auto& ch : s2) a[ch - 'a'] -= 1; for(int i = 0; i < 26; ++i) if(a[i] != 0) return false; return true; }};