problem:https://leetcode.com/problems/bulls-and-cows/
tips:
string str;
ostringstream osst(str);
osst<<correct_cnt<<"A"<<missing_cnt<<"B";
cout<<str<<endl;
return osst.str();
最后str为空,osst.str()不为空。
这样写:
ostringstream osst();
osst<<correct_cnt<<"A"<<missing_cnt<<"B";
return osst.str();
会报错。osst()初始化为空之后,不能向其输入。
找正确的匹配字符,然后记录其余的字符计数,然后匹配数量。