vector<string> uncommonFromSentences(string A, string B){ unordered_map<string, int> record; int lenA = A.size(), lenB = B.size(); string temp = ""; for (int i = 0; i < lenA; ++i){ if (A[i] == ' '){ auto iter = record.find(temp); if (iter != record.end()) ++iter->second; else record.insert(pair<string, int>(temp, 1)); temp = ""; } else temp += A[i]; } auto iterator = record.find(temp); if (iterator != record.end()) ++iterator->second; else record.insert(pair<string, int>(temp, 1)); temp = "";
for (int i = 0; i < lenB; ++i){ if (B[i] == ' '){ auto iter = record.find(temp); if (iter != record.end()) ++iter->second; else record.insert(pair<string, int>(temp, 1)); temp = ""; } else temp += B[i]; } iterator = record.find(temp); if (iterator != record.end()) ++iterator->second; else record.insert(pair<string, int>(temp, 1)); temp = "";
auto iter = record.begin(); vector<string> result; for (; iter != record.end(); ++iter){ if (iter->second == 1) result.push_back(iter->first); } return result; }