4
this question is absolutely frustrating 🙂10
vector<string> split(string s) {13
for (int i = 0; i < s.length(); i++) {26
this function checks the second condition.28
bool check(string s, string time, string city, map<string, vector<string>> mp) {29
for (auto x : mp[s]) {30
vector<string> out = split(x);31
int val1 = stoi(out[1]);32
int val2 = stoi(time);33
if (out[3] != city and abs(val2 - val1) <= 60) {40
vector<string> invalidTransactions(vector<string> &transactions) {41
vector<string> res; /* stores the result */43
map<string, vector<string>> mp; /* to search for only that person*/45
int n = transactions.size();47
vector<vector<string>> v(n, vector<string>(4)); /*ith v stores info about ith transaction*/50
for (auto x : transactions) {51
vector<string> out = split(x);53
mp[out[0]].emplace_back(x);57
for (int i = 0; i < n; i++) {58
if (stoi(v[i][2]) > 1000) {60
check for first condition62
res.emplace_back(transactions[i]);65
checks for second condition.67
if (check(v[i][0], v[i][1], v[i][3], mp)) {68
res.emplace_back(transactions[i]);