Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vector<string> invalidTransactions(vector<string>& transactions) {
- unordered_map<string, vector<vector<string>>> name_tr;
- unordered_set<string> res;
- for (auto cur_tr :transactions)
- {
- istringstream ss(cur_tr);
- vector<string> s(4, "");
- int i = 0;
- while(getline(ss,s[i],',') )
- {
- i++;
- }
- if(stoi(s[2])>1000) res.insert(cur_tr);
- for (auto past_tr: name_tr[s[0]])
- {
- if (past_tr[3] != s[3] && abs (stoi(past_tr[1]) - stoi(s[1])) <= 60)
- {
- res.insert(past_tr[0]+","+past_tr[1]+","+past_tr[2]+","+past_tr[3]);
- res.insert(cur_tr);
- }
- }
- name_tr[s[0]].push_back({s[0],s[1],s[2],s[3]});
- }
- vector<string> r (res.begin(), res.end());
- return r;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement