Amazon Interview Question for SDE1s


Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
2
of 2 vote

How about a HashMap where scientist is key and there is a linked list of black_holes for the value if the scientist can query multiple black holes.

And the black_hole can it self contain some information about its identity and a linked list of queries made:

HashMap<Scientist,List<BlackHole>>
Class BlackHole{
	Identity;
	List<Query>;
}

Class Query{
	QueryType;
	QueryResult;
}

- deepanshu February 03, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

correct......
becz we have N scientist and k black hole and one scientist can make query at most k black hole..

- sumit.polite February 03, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Absolutely correct. As the number of queries will be much more than number of black holes, so the composition of queries in black hole makes sense.

- Amit Kehri March 03, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Absolutely correct. As the number of queries will be much more than number of black holes, so the composition of queries in black hole makes sense.

- Amit Kehri March 03, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Absolutely correct. As the number of queries will be much more than number of black holes, so the composition of queries in black hole makes sense.

- Amit Kehri March 03, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Absolutely correct. As the number of queries will be much more than number of black holes, so the composition of queries in black hole makes sense.

- Amit Kehri March 03, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I would use a hash with key = scientist id, and a value containing a nested hash with key = black hole id and value = bit map of size 3 (1 bit for each query).

- sk3l February 05, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If we look into the problem, it is more like a bipartite graph with n+k vertices. It seems to be most natural to represent it through an adjacency matrix.

- Nikhil October 27, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It's more like a bidirection many-to-many relationship. Hole and Scientist class should have array of the other type for reference. That means you need to have some sort of manager class to maintain the relationship

// Many-To-Many bidirection
class Hole {
  private id,
  private temperature,
  private radius,
  private size,
  // some getters
  private List<Scientist>,
  public addScientist(Scientist)
}

class Scientist {
  private id, // or name, whatever
  private List<Hole> holes
  public query(holeId) // this calls the QueryManager 
}

class QueryManager {
	private Holes[] // all hole objects
        public Query(int holeId, scientist) // this should find the hole, add the scientist to the array in the hole. return the hole object.
	
}

- Judy Huber July 26, 2016 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

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.

Learn More

Resume Review

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.

Learn More

Mock Interviews

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.

Learn More