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.
Simple approach by use % and / operator with size of array.
- rverma January 25, 2016e.g {2, 4, 3, 1, 0}
1. new value of A[0]= A[2] ,
so newValue= A[2]%size; (old value of A[2])
A[0]= A[0]+newValue*size; by doing this step, we have old value of A[0]=A[0]%size , new Value of A[0] = A[0]/size;
do this for every element
2. When first loop complete and every element has updated value(both old and new value) then run another loop and do A[i]=A[i]/size;
then every index of array has new value.
code based on above aproach
int size=A.length;
int newValue=0
for(int i=0;i<size;i++){
newValue=A[A[i]]%size;
A[i]=A[i]+newValue*size;
}
for(int i=0;i<size-1;i++)
A[i]/=size;
Time complexity is O(n) and auxillery space complexity is O(1)