检查字符串是否相等

bool checkSame(std::string a, std::string b)
{
    constexpr int size = 145;
    std::vector<int> count(145);
    std::for_each(a.cbegin (), a.cend (), [&](char c){++count[c - ' '];});
    std::for_each(b.cbegin (), b.cend (), [&](char c){--count[c - ' '];});
    return std::find_if(count.cbegin (), count.cend (),
                        [](int i){return i != 0;}) == count.cend ();
//    std::sort(a.begin (), a.end ());
//    std::sort(b.begin (), b.end ());
//    return a == b;
}

 

posted @ 2016-02-15 02:15  wu_overflow  阅读(138)  评论(0编辑  收藏  举报