题解 | #字符串字符匹配#
字符串字符匹配
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";
}