20.11.22 leetcode242

题目链接:https://leetcode-cn.com/problems/valid-anagram/

题意:判断两个字符串是否是字母都相同,只是顺序不同

分析:非常脑瘫,直接排序。。。

class Solution {
public:
    bool isAnagram(string s, string t) {
        sort(s.begin(),s.end());
        sort(t.begin(),t.end());
        if(s==t)return true;
        else return false;
    }
};

 

posted @ 2020-11-22 21:16  清酒令  阅读(51)  评论(0编辑  收藏  举报