Dídac Pérez
BAN USERGood question. Map and Heap, no more.
- Dídac Pérez October 31, 2014Oookay... enough. Thank you so much anyway :)
- Dídac Pérez December 09, 2013Yes, you are right. But, why in the world would you answer my question with a simple "Not O(n)" instead of giving me the run time of my code?
- Dídac Pérez December 09, 2013Could anyone tell me if my solution is O(n)?
std::vector<std::string> strings;
strings.push_back("hola");
strings.push_back("adeu");
strings.push_back("heli");
strings.push_back("caca");
strings.push_back("caca");
strings.push_back("pedo");
strings.push_back("heli");
strings.push_back("adeu");
strings.push_back("hola");
std::unordered_set<std::string> set;
for (unsigned int k = 0; k < strings.size(); ++k)
{
std::string string = strings.at(k);
set.insert(string);
}
int count = set.size();
I think the interviewer wanted you to understand that an array must be contiguous and not a linked list. That is, you must have capacity, which is the amount of memory allocated, and size, which is the actual size of the array. So, when the user resizes the array with size > capacity, you must reallocate memory and copy the values from the old to the new array.
- Dídac Pérez December 08, 2013Best answer ever.
- Dídac Pérez December 08, 2013I think a possible approach would be sorting both log files which will take O(nlogn) and, after that, read both files by chunks simply comparing the usernames and skipping when the username in one list is lower than the other one. Some kind of merge search...
- Dídac Pérez December 08, 2013I don't get the "10^18 buckets for alphanumeric strings of length 10". Did you mean 36^10?
- Dídac Pérez December 08, 2013that values must be parameters, thus they are not relevant.
- Dídac Pérez October 20, 2013You can establish a connection without sending the GET command in order to keep the connection opened.
- Dídac Pérez October 20, 2013
I would give no answer. No answer, no sentence :)
- Dídac Pérez November 04, 2014