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.
O(n) solution :
- suresh.raj.07 March 29, 20121. Run the slow pointer and fast pointer algorithm. The point where you stop lets call it at node A.
2. Now get the two lengths like below:
2.1 - start from node A->next and come back to node A. Length = X.
2.2 - start from head and come to node A. Length = Y.
3. Now assume X > Y then calculate X-Y. Treat X as Y and v.v. if Y > X
3.1 - start from A->next go (X-Y) nodes further and mark is pointer m.
3.2 - start another pointer n from head and let pointer m and n go together they will meet at the node where the circle starts :) - yes they will. Lets say both of these pointers have traveled Z nodes.
3.3 - now length of the list = X + Y - (Y-Z) = X + Z.
Edit1:
Looks like this solution is already posted by "my solution" ...