is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
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.
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.
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.
Edit: The following cases would probably break this, so it is back to being a gross mystery. I previously assumed that if the left-most pos/negIndex passed the rightMost, that it would swap with the overflowIndex instead, but it is more tricky than that- especially if you end up with the leftMost between the overflow and rightMost. This is an obnoxious question that is hopefully a fake. It would make sense if it was less constrained in the beginning and the last set of constraints was a hail-mary for discussion, but it is terrible.
I believe that you can accomplish this by using a third pointer, but keeping track of everything is annoying. You are basically simulating three arrays in memory using one array- you will have a positive pointer, a negative pointer, an overflow pointer.
Pretend that you do not have a memory constraint: You can go through the input array and create two separate arrays- one for negative and one for positive numbers. You would then go through the input array again, filling in the even/odd positions with the next number from the appropriate array. Ex:
To solve the problem with the memory constraint, as you will iterate through the input array, keeping pointers to the next positive and next negative number. This won't work if you encounter a long series of positives or negatives, unless you want to constantly shuffle the values (n^2), which is why you need an overflow pointer. For the overflow pointer, you can assume that it will always be behind at least one of the other pointers, so its values should be same as the farthest pointer. Ex:
iterPos = 3
posIndex = 3
negIndex = 7
overflowIndex = 6 <- overflow value will be negative, so iterating through its values won't be confused with real positive values, then the end of the array will be bounded by the negIndex
There are of course tons of edge cases to keep track of when dealing with 4 indices and even vs. odd positions, which is why I do not have code yet- this would be a terrible question to be asked if the interviewer expected code. You can run through this with bigger data sets as a proof of concept- that is another annoying thing, you need to have larger data sets to verify (it takes some effort to believe):
- Ritz August 28, 2014