Topcoder-SRM597DIV2-500

#include
#include
using namespace std;
#include
class LittleElephantAndString{
public:


int getNumber(string A,string B){
string tA,tB;
tA=A;tB=B;
sort(tA.begin(),tA.end());
sort(tB.begin(),tB.end());
if(tA.compare(tB)!=0)
return -1;
int c=B.size()-1;
for(int i=A.size()-1;i>=0;i--){
if(A[i]==B[c])
c--;
}
return c+1;
}
};

你可能感兴趣的:(算法)