Uber | Phone Screen | Amsterdam

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2024-02-13Added By Anonymous
Source: Link

Company: Uber

Interview Stage: Phone Screen

Location: Amsterdam


Original Post Content:


Given two inputs,


First input is the location map, a 2D array


| O | E | E | E | X |

| E | O | X | X | X |

| E | E | E | E | E |

| X | E | O | E | E |

| X | E | X | E | X |

{{'O','E','E','E','X'},{'E','O','X','X','X'},{'E','E','E','E','E'},{'X','E','O','E','E'},{'X','E','X','E','X'}}


Second input is the query. It’s a 1D array consisting of distance to the closest blocker in the order from left, top, bottom and right

[2, 2, 4, 1] -> This means distance of 2 to the left blocker, 2 to the top blocker, 4 to the bottom blocker and 1 to the right blocker


The location map boundary is also considered blocker, meaning if the robot hits the boundary it also means it’s hitting the blocker.


Task: Write a function that takes these two inputs and returns the index of the robots (if any) that matches the query that we’re looking for.

Answer: [[1, 1]]

Comments