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.
/*
*
* On my first thought, I will loop through array one-by-one. If find 0, move to the end of element. Otherwise, do nothing.
*
* If you ask about time complexity and space.
*
* It would take O(n^2) in the worst case because we would have to move all elements to its front by 1.
* Space would be O(1)
*
* PseudoCode
* Func MoveZeros(array A)
* 1. loop i in array A
* 1.1 if i == 0 then tmp = i
* 1.2 Move all element after i up by 1 element
* 1.3 Put i in the last element of array A
*
* We can do better by giving index pointer of "k" at the end of array to recognise all zero elements we put at the end of array.
* So, we will loop through element of array from beginning but if we find 0, we will swap that element with index "k"
*
* PseudoCode
* Func MoveZeros(array A)
* 1. set k = A.size() - 1
* 2. loop i = 0 -> A.size()-1 and i < k
* if a[i] == 0; then
* - swap a[i] with a[k]
* - k--
* - i++
* else
* - i++
*
* How about time complexity and space for this?
*
* Time complexity : O(n)
* Space complexity : O(1)
*
*/
The final code is below where we can add number to stdin.
- parnurzeal November 30, 2014