Amazon Interview Question: I was asked two questions - h... | Glassdoor

Interview Question

Software Development Engineer Intern Interview Seattle, WA

I was asked two questions - how will you know which is the

  starting point in a circular linked list (write a program) and write a program to return two numbers from a function to the main
Answer

Interview Answer

1 Answer

0

Write a program to know which is the starting point in a circular linked list
This is a fairly straightforward question
Easy answer:
Iterate through linked list
 - Compare each node to every previous node:
  - If different, continue
  - If the same, you've reached the first circular node

Write a program to return two numbers from a function to the main
Easy answer (considering pointer access):
Take one or both numbers as an "in" parameter to the function
If both are "in" parameters, write them both in the body of the function
If only one is an "in" parameter, write it in the body, and return the other.

Anonymous on Jan 8, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.