Amazon Interview Question for SDE-3s


Country: United States
Interview Type: In-Person




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

For question 1 you can use a Balanced Interval Tree.
For question 2 you can get geoLocation of the mobile application and use near functionality in mongo.

- Anonymous March 06, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
2
of 4 vote

Just use an array. Balanced interval tree is too fancy for storing 4 entries. Interview questions are not for showing off how much you have crammed but showing that you are also making good choices.

- J March 07, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Assuming prices are charged by hour, the most efficient (and simpler) way of storing the price rules is just an array:
arr[h] = price --> where h = hours - 1
This gives you O(1) query time and O(1) (hours are limited to 24) storage time

While a Balanced Interval Tree makes sense for a more general case, you should always consider the specifics of the problem.

For the architecture design point. I think the previous answer is a good idea:
" you can get geoLocation of the mobile application and use near functionality in mongo."

For a more vendor agnostic (and architecture complete) solution:
- get the customers location from the mobile device's location service (could be GPS or whatever)
- send the location to a (load balanced) web server to solve the request
- the web server will consult a k-d tree-like structure to find the corresponding price map, given the coordinates (could be another service)
- the price map will be as described before

Of course, you should have some caching mechanism in your architecture if you expect to scale.

- Matias SM March 06, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Store in a vector array so that its extensible, use direct indexing either using hash to find right entry

For APP -
APP ------ HTTP REST GET (apps lat/long) -----> Server
App < -------- 200OK (JSON - list of nearby stores --- Server

At server:
Have a Parking DB model with -
lat
long
nfreespaces

For searching - use Apache solr or elastic search geodist utility .... search engines

- Anonymous March 14, 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