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.
This for sure should not take O(n^2).
- AjkPCa August 20, 2014You can tell what you need in an item at that specific item. There is just a few extra edge cases. Runtime O(n). Algo should go like this.
For all numbers:
- check if the number is "1" if not, always use multiply.
- if number is "1", our goal is to minimize a sum >= 3. So check previous and next items.
- If no ones, pick the smallest of the two, to put in brackets and add.
- If there is a one in next, go to next->next.
- If next->next still a one, put the 3 in brackets (you have your golden 3 ideal). and move your pointer.
- Otherwise check for twos. If on both sides of both ones there are twos, then and only then your wanna seperate the ones with the twos. (as the example above). Otherwise, couple the two ones together and move the pointer.
For negative.
- Do same as above, while keeping track of number of negatives. (note negatives will be treated as non-ones! Keep track of the smallest negative number position.
- If number of negatives is even, do nothing.
- If number of negatives is odd, get the smallest negative number and change its signs from multiply to addition on the side for which the first sum > 0, is smaller.
- For 0 remember you have to always add on both sides, no matter what.