首页 > 其他 > 详细

检查字符串是否相等

时间:2016-02-15 07:02:05      阅读:267      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!