Epic Systems Interview Question






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

4 billion integers sum......???

- conquersky September 21, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

4,3,-3? integers can be negative

- Anonymous October 05, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

use bit hashing ..........

- Anonymous September 21, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

even if you use just one bit per number you dont have enough bits (so using a 10mb memory as an array of 1 bit cells containing a 1 if its array index is part of the list wont work)

- Anonymous October 05, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

4*10^9 < 4 * 2^30 = 2^32 = 1MB, so why can't you fit that in memory?

- roger October 29, 2009 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

sorry I was wrong, look at programming pearls Col2, there's a beautiful solution.

- roger October 29, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

where which problem in Col2? Thanks.

- Anonymous February 18, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

question repeated from this forum.

- Anonymous September 22, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I don't know if I get the question correctly, but I guess one iteration over all the numbers is a must. So, either find the max or min of the 4 billion numbers. The max + 1 or min - 1 is the number that doesn't exist in the file. O(n)

- Anonymous October 05, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Good idea, then, we can use
fgetpos to record the position of the last reading,
and then use fsetpos to go the position of last reading.
We keep an variable for max or min
Therefore, we can go one iteration with 10MB

- creation October 22, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

If the max = MAX_INT and min = MIN_INT then max+1 and min-1 would cause integer(unsigned long long or whatever) overflow.

- Anonymous February 12, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

That is a language constraint not a limitation of the proposed algorithm, you might be talking about C or C++, I am not sure.

- Kannan November 07, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

we need to store the [range] of available numbers. lets start with [min,max] inclusive.
now on iterating, we ll split the range if we come across a number in existing ranges.
for example, if we get 10, then our ranges become {[min,9]; [11,max]}.

algorithm:
1. init ranges to {[min,max]}
2. for each number k
3. if k is in any of the ranges, split the range
4. if k is the only number that can be in a range (say [k,k]) then delete the range from the list of ranges.

after iterating, pick a number from the list of ranges.

time O(n)
worst case space O((2^16)/2)
assuming 2 bytes per int, ints are not sorted and diff between consecutive ints >= 2
takes 32mb for storing range values.

best case space O(4)
ints are sorted and diff between consecutive ints is <= 1
takes 8 bytes for storing range values.

- 1_of_101_soutions April 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

All you need is 2 int variables. Store 0 in one of the variable. Read the 1st integer from the file into the 2nd variable. Get the greatest out of the two. Get the next integer from file and compare to the greatest which you already have. Repeat till you have the greatest number. Add 1 to it and that is the number which is not in the file.
NOTE: int in any language has constraints to what is the greatest number it can hold or else there will be overflow.

- Mukund February 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The question is very unclear. Mukund's solution will not work if the file contains 1 2 4 5 ...here the missing number in the file is 3 and not max+1 which is 6

- einstein010 April 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

This is a classic question.
Based on limited memory, how to sort numbers with a large amount.
Method: external sorting. (wekipedia)

- Kevin February 21, 2013 | Flag Reply


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