Unity 3D Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
what's a higher programming language? Is Perl? Is Bash? You basically only need a way to parse the file and an associative dictionary (ideally a hash table) and then you need a block function you can somehow call.
Does it make sense to block on requests per IP only? It might be a proxy server or many users sitting behind a NAT. ... anyway, iterate the logs and count per IP using a hashtable should do it.
Yes, this can be done with a few lines of bash on the console. It is O(n^2 log(n)) in time where n is the #lines in the file, with O(1) in space. The nlog(n) is only because uniq does not work without the sort.
It can be optimized in time, by trading off space and using a hash. At that point, you will need a higher-level scripting language like Python or Bash (or Perl), which is trivial to write. By using a hash, you can have O(n) time complexity, with O(n) space.
Input text file:
Output:
- havanagrawal November 13, 2017