Uber Interview Question for Backend Developers


Country: United States
Interview Type: In-Person




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

We can use an 2-d array as a Data structure. (By assuming all the cabs are discretely present inside a cell).
We can always calculate the distance from the focal point, from which the cab is called.

- chandansr.in June 11, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

But in this case u need to calculate distances for all cab points from the focal point, we need to do this more efficiently.

- ANONU June 11, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

use geohash, and tries on that . we can find the nearest cabs which are following under same parent.

- gopi.komanduri June 12, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Basically they wanted me to implement geohash. Any hints how to go abt that?

- ANONU June 13, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Quadtrees ? In case it was from a design perspective

- Pranjal June 14, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Quadtrees ? In case it was from a design perspective

- Pranjal June 14, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Quadtrees ? In case it was from a design perspective

- pj.thegame June 14, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Maintain a grid of latitude and longitude of some particular length and set of cabs in each grid element.

So if a cab moves from one grid to another. You can update the grid sets in O(1) time.

When a user at position(uLat,uLong) queries for cabs within a radius r, we will process all grid elements between (uLat-r) to (uLat+r) and (uLong-r) to (uLong+r). For every cab in such grid element, we check whether they are at a distance r from the user. This takes O(total no. of cabs considered) or O(total no. of grids considered) time.

- yakkala July 27, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You can use BFS. start from source node and mark distance as 0. If any point in time if distance of node exceeds radius. then return back.

- Anonymous August 21, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Consider if need to calculate the distances between coordinates, to be efficient hash can easily avoid recalculating the distances of two coordinates.

- Anonymous September 13, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Simply use a K-D tree using long and lang as 2 dimensions of each node and build a K-D tree based on long, lat of all cabs and search the position of user in the K-D tree and while searching check if euclid dist(user,cab) <=R.

Updation: O(logn)/ O(d)
Search: O(logn)/ O(d)
d->max depth of K-D tree.
n->current number of cabs.

A more refined solution will be to create a grid for the location by maintaining a K-D tree with a threshold depth and group cabs according to criteria then simply search with user's location and assign valid groups.

- rexwulf October 08, 2018 | 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