题解 | #字符串字符匹配#

字符串字符匹配

http://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93

#include<bits/stdc++.h>
using namespace std;

string uni(string str)
{
    for(int i =0;i<str.size();i++)
    {
        for(int j=i;j<str.size()-1;j++)
        {
            if(str[i] == str[j+1])
            {str.erase(j+1,1);
             j--;
            }
        }
    }
    return str;
}

int main(void)
{
    int count =0;
    string str,str1;
    cin>>str>>str1;
    str = uni(str);
    str1 = uni(str1);
    sort(str1.begin(),str1.end());
    sort(str.begin(),str.end());
    int i=0;
    for(int j =0;j<str1.size();j++)
     {
           if( str[i] == str1[j])
           {count ++;
            i++;}
        }
    if(count == str.size())
    {
        cout<<"true";
    }
    else cout<<"false";
}
全部评论

相关推荐

LazyBreeze:项目尽量体现你对技术的理解和深度,不是说把中间件用一下就完事了,你项目里面提到集群和分布式,你真在服务器上部署过吗,感觉太假了,第二个项目说自己用了微服务的什么组件,只是用了没有自己的思考,很难让面试官注意到你的简历。针对某几个技术点自己多思考一下,考虑一下有没有别的替代方案,可以写一下,即使没有真的实现
点赞 评论 收藏
分享
头顶尖尖的程序员:我也是面了三四次才放平心态的。准备好自我介绍,不一定要背熟,可以记事本写下来读。全程控制语速,所有问题都先思考几秒,不要急着答,不要打断面试官说话。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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