242. Valid Anagram

 1 static int wing=[]()
 2 {
 3     std::ios::sync_with_stdio(false);
 4     cin.tie(NULL);
 5     return 0;
 6 }();
 7 
 8 class Solution 
 9 {
10 public:
11     bool isAnagram(string s, string t) 
12     {
13         vector<int> sv(256,0),st(256,0);
14         for(char c:s)
15             sv[c]++;
16         for(char c:t)
17             st[c]++;
18         return sv==st;
19     }
20 };

判断一个字符串是否为另一个字符串的乱序重组字符串。判定其字母构成相同即可。

猜你喜欢

转载自www.cnblogs.com/zhuangbijingdeboke/p/9083931.html