3
vector<string> getFolderNames(vector<string> &names) {4
// You can understand the code by seeing explanation below6
unordered_map<string, int> mp;13
while (mp[val] != 0) {14
val = i + '(' + to_string(cnt) + ')';19
res.emplace_back(val);23
// For better Understanding Code explained Line by line25
// names = ["d", "d(1)", "d(2)", "d"]29
// cnt = mp[val] = mp["d"] = 0;30
// mp[val] = 0, so while loop not executed31
// mp[val]++ -> mp["d"] = 0+1 = 1;35
// mp["d(1)"] = 0+1 = 1;36
// res = ["d", "d(1)"]39
// mp["d(2)"] = 0+1 = 1;40
// res = ["d", "d(1)", "d(2)"]42
// now, i = "d", val = "d";43
// cnt = mp[val] = mp["d"] = 1, (appeared before)44
// while loop executed bcoz mp[val] = 1 which is greater than 047
// val = i + '(' + to_string(cnt) + ')' = "d(2)"48
// mp[i] = mp["d"] = cnt = 2;50
// now mp[val] = mp["d(2)"] = 1, (appeared before)51
// while loop executed bcoz mp[val] = 1 which is greater than 054
// val = i + '(' + to_string(cnt) + ')' = "d(3)"55
// mp[i] = mp["d"] = cnt = 3;57
// now mp[val] = mp["d(3)"] = 059
// mp[val]++ = mp["d(3)"] = 0+1 = 1;60
// res = ["d", "d(1)", "d(2)", "d(3)"]