class Result {
public:
vector<int> calcResult(string A, string guess) {
// write code here
multiset<char> s;
string miss;
int win = 0;
int fakeWin = 0;
vector<bool> table(A.length(), false);
for(int i = 0; i < A.length(); ++i)
{
if(A[i] == guess[i])
{
win++;
table[i] = true;
}
else
{
miss.push_back(guess[i]);
}
}</bool></char></int>
for(char c : miss)
{
for(int i = 0; i < A.length(); ++i)
{
if(c == A[i] && !table[i])
{
fakeWin++;
table[i] = true;
break;
}
}
}
return {win, fakeWin};
}};

京公网安备 11010502036488号