Flipkart Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

geohash the lat long, if the precision counts go for the entire range or else just index the first 8 bytes of lat/long, do a bird eye with radius expansion using geohash algorithm and you have the locations latlong, distance from the centre (provided latlong), take the latlong geohashes in the range, match against the indexed latlong geohash and you should have the places.. i guess.

- sanjay singh December 11, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

bang on. this is how geospatial indexing and geonear search happens.

- pinakithegreat January 18, 2015 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Just iterate through your location hash and for each coordinate check whether the coordinates follow the following formula

Consider my position to be (x,y)
Let the point under consideration be (x1,y1)

A given point will lie within or on a circle of radius r with center (x,y) iff
(x1 - x)^2 + (y1-y)^2 <= r^2

- Saurabh Raje December 18, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You can find the bounding rectangle for your position.

Check for lat and long that lie within the the bounding rectangle

for lat, long within the bounding rectangle check euclidean distance.

- Mumbaiya_Chori December 03, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It won't be euclidean distance it will be the distance along the sphere

- Mumbaiya_Chori December 03, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

arrange one element(lat or long) in sorted order in a array. Find out the nearest place using the element(lot or long, what ever you made key of sorting). Now, search for nearest place arround inside the circle.

you are done.

- Anonymous December 10, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

one Solution i think for this is:

1) Create a graph with [lat,long] as vertices and edges. Edge weight can be calculated as the distance between two vertices.

2) to find famous locations for a given [lat,long], take all edges whose weight is less than r (as given in question) and edge source/destination is a given[lat,long]

Time complexity will be O(N-1) where N = number of edges.

Pros: Search time will be less for any given [lat,long] as we stored the graph.
Cons: adding/removing new [lat,long] will take more time.

- kiran007 December 25, 2014 | 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