Unity 3D Interview Question for Software Engineer / Developers

Country: United States
Interview Type: In-Person

Comment hidden because of low score. Click to expand.
of 1 vote

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.

for ip in $(sort IP.txt | uniq)
	count=$(grep -c "$ip" IP.txt); 
        # 5 is just an arbitrary number, you could ask your interviewer for the limit
	if [[ count -ge 5 ]]; then    
		echo "BLOCK $ip"

Input text file:



- havanagrawal November 13, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

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.

- Chris November 04, 2017 | Flag Reply

Add a Comment

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.


is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More


CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More