题解 | #确定两串乱序同构#

确定两串乱序同构

https://www.nowcoder.com/practice/164929d4acd04de5b0ee2d93047b3b20

#include <algorithm>
#include <string>

class Same {
public:
    bool checkSam(string stringA, string stringB) {
        // write code here
        sort(stringA.begin(), stringA.end());
        sort(stringB.begin(), stringB.end());
        if(stringA == stringB){
            return true;
        }
        return false;
    }
};

先将string进行排序(以ASCII值),然后直接相比较就行了

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务