Zynga Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

How will you do it in linear time and constant space?

- A July 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This approach doesn't seem to be constant space. It's linear space - i.e. creating a new array that's within a constant of n, the length of the original array.
If the array isn't sorted, this cannot be done in linear time, so I'm assuming that the array is sorted.
Sorry I'm just a little confused by the question. Am I way off base here?

- panoptic.biopower December 12, 2012 | Flag
Comment hidden because of low score. Click to expand.
2
of 4 vote

Suppose the array has numbers ranging from 20 to 200. Declare an array of size (200 - 20) = 180 and initialize all values to 0. Let's call this array duplicates.
Suppose the array in which we have to find duplicates is named arr.
Loop through arr. For every arr[i] increment duplicates[arr[i] - 20].
After the loop is complete, duplicates[i] will hold the number of times (i + 20) occurred in arr.

- Bonzo July 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

it's basicly counting sort, and it's O(n)

- m4yers October 06, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

How will you do it in linear time and constant space?

- A July 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Shouldn't thr be some heuristic given such that numbers in array are of a particular range or something like that??

- Yoda July 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 votes

Its O(lg n) for each node. You will end up inserting n nodes in worst case, that's O(n lg n).

- gats July 08, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes, thats correct, each insertion will taken O(log n) time and overall it will take O(nlogn)

- Anonymous July 09, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Haha

- loveCoding July 10, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

lol!:P

- Avenger August 09, 2012 | Flag


Add a Comment
Name:

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

Books

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

Videos

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