码迷,mamicode.com
首页 > 其他好文 > 详细

检查字符串是否相等

时间:2016-02-15 07:02:41      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:

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;
}

 

检查字符串是否相等

标签:

原文地址:http://www.cnblogs.com/wuOverflow/p/5189840.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!