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.
I suppose there are two scenarios to look at
- JK31 July 06, 20191. n(number of swaps)>=(number of swaps required to bring biggest element in front of subarray under consideration)
2. n(number of swaps)<(number of swaps required to bring biggest element on top of subarray under consideration)
for case 1, find biggest ele, bubble it up till it reaches front, fix the pos(i), update n(number of swaps left), repeat process for subarray A[i+1]...A[length-1].
for case 2, start after fixed pos in case 1, keep swapping A[i] with A[i+1] if A[i]<A[i+1], update n, repeat until n becomes 0.
in case one, we will start from biggest element and bubble up, till it comes to the top then decrement n by n-(number of swaps used). Find next big element from next element.. keep repeating.
in case 2, we will start from top and find the pair which follows A[i]<A[i+1] and swap