Uber Coding questions OA

Location
san francisco
Posted
7 Apr 2021
373 reads

Summary

I recently completed the online assessment for Uber, which featured two distinct coding challenges: a Word Wrap problem with a dash-separated output and a Nearest Exit problem on a 2D board.

How it went

I took the online assessment for Uber for a role in San Francisco. The assessment presented two primary coding questions. The first involved a Word Wrap problem where I had to format a list of words into lines of a maximum length, separated by dashes. The second question was a maze-solving problem, specifically finding the nearest exit from a given entry point on a 2D board with obstacles.

Questions asked (2)

  1. 01

    Word Wrap with Dash Separator

    Data Structures & Algorithms

    Given a list of words and a max line length, create a function that returns a wrapped list with dash separated words.

    EXAMPLE
    input:
    ["Tom","is","a","dragon","that","breathes","fire"]
    maximum length of characters per line = 9

    output:
    ["Tom-is-a-",
    "dragon-t-",
    "hat-brea-",
    "thes-fire"]

  2. 02

    Nearest Exit in a Maze

    Data Structures & Algorithms

    There is an m x n rectangular 2d array called board which has rows and columns containing '0' or '+' only.
    Rows and columns start at index 0.
    The '0' value means it is a passable path whereas the '+' value is a wall that cannot be crossed.
    You are a snake that can move in four directions- up, down, left, right. Entering and exiting the board must only happen at a '0' value. You can enter the board from any four sides/borders.
    After entering the board, there can be multiple exits. Find the nearest exit.

    EXAMPLE

    + 0 0 + + +

    • 0 0 0 + +
        • 0 + +
        • 0 + + 0 + 0 0 0 0 0 0 0 + + +

    board = [
     ['+', '0', '0', '+', '+', '+'],
     ['+', '0', '0', '0', '+', '+'],
     ['+', '+', '+', '0', '+', '+'],
     ['+', '+', '+', '0', '+', '+'],
     ['0', '+', '0', '0', '0', '0'],
     ['0', '0', '0', '+', '+', '+']
    ]

    find_exit(board, (4, 5))

    OUTPUT
    (5,2)

    EXPLANATION
    You are given the board array and a set of coordinates. 4 is the rowId, 5 is the columnId for entry. There are multiple exits. The goal is the find the nearest exit. Exit is at row 5 column 2. Answer is (5,2).

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Uber recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!