题号:无
难度:Easy
链接:https://leetcode.cn/problems/check-permutation-lcci/
思路
设两个map
,分别一轮统计字符出现次数,相等即为重排。感觉还是挺暴力的?
代码
class Solution {
public:
bool CheckPermutation(string s1, string s2) {
if(s1.size()!=s2.size()) return false;
map<char,int> m1,m2;
for(char c:s1) m1[c]+=1;
for(char c:s2) m2[c]+=1;
return m1==m2;
}
};
Comments NOTHING