# Uber Interview Experience for SDE-1 | Off-Campus 2021

• Difficulty Level : Hard
• Last Updated : 06 Jul, 2021

Uber started an off-campus drive in the first week of June. I got a referral through a college pass-out. After a week, I got the test link for the online coding round.

Online Coding Round(60 minutes): There were four coding questions(some students got three questions). The test was conducted on the CodeSignal platform.

1. Given an array A of N elements, you can perform the following operation any number of times(possibly 0) – you can replace any integer of the array with an integer. Your task is to print the minimum operations required to make the elements continuous.

Constraints: 1 <= N <= 1e6, 1 <= A[i] <= 1e9

```Example:
Input: 4 7 11 6 9
Output: 2
Explaination:
We can replace 11 with 5 and 9 with 8,
resulting in the array [4, 7, 8, 6, 5]
which contains all the elements from 4 to 8.```
1. Given N ropes and an array A representing the length of the ropes. You can divide the rope into several ropes. Output the maximum length of rope you can achieve with the count of at least K from the given ropes.

```Example:
Input:
4 2//N K
1 3 4 9 // Array A
Output: 4
Explanation:
We can cut the rope with length 9 as (4,4,1).
So, total count of ropes with
length 4 equals to 3 >= K i.e. 2
This the maximum length you can
achieve with the count of at least 2```
1. Given a size N x M floor, you have a cleaning robot that can clean a tile it visits. Initially, all tiles are dirty and the robot is at (0,0). The robot has a battery of size K and it can move in all four directions. For each move the robot makes, its battery reduces by 1. The floor contains obstacles on some tiles represented by 1 in the given matrix and the robot cannot move on these tiles. Output the maximum number of tiles the robot can clean such that it has to return to its initial position before running out of battery.

Constraints: 1 <= N x M <= 100, 1 <= K <= 12, 0 <= Floor[i][j] <= 1

```Example:
Input:
4 4 6 // N M K
0 0 0 0
0 1 0 1
0 0 0 0
Output: 4
Explaination:
The robot can choose this path
(0,0)-> (1,0) -> (2,0) -> (2,1) and
Robot cannot choose the other path because it will run out
of battery before reaching the initial position.
So, total number of distinct tiles visited and cleaned = 4.```
1. Given an array A consisting of N elements, you need to perform the following operations: – remove p elements from the array – remove q groups of consecutive elements of size 2 – remove r groups of consecutive elements of size 3 After performing the operations, the left and right array formed are merged. Output the maximum possible sum after performing the operations.

Constraint: 1 <= N <= 1e5, 1 <= p+2*q+3*r <= N

```Example:
Input:
7 1 1 1 //N p q r
4 5 2 1 3 6 7
Output: 7
Explaination:
For p=1, you can remove 1 from the
array -> [4,5,2,3,6,7]

For q=1, you can remove 2 and 3
which is group of consecutive elements
of size 2 -> [4,5,6,7]

For r=1, you can remove 4,5 and 6
which is group of consecutive
elements of size 3 -> 
The maximum possible sum of
array equals to 7.
(Note: There are other ways to remove elements
which will give the same result)```

I was able to solve the first three problems completely and the last one partially(7/8 test cases). I got a mail after few days regarding the interview schedule and the number of rounds. Only 95 out of 3,00,000 applicants were selected.

It was a one-day recruiting process that consisted of two technical rounds and one HR round. Each round was an elimination round.

Technical Round 1(45 minutes): The interviewer was very friendly and helpful throughout the interview. He introduced himself and asked me to do the same. Then he quickly moved on to the coding question. The interview was conducted on the CodeSignal platform.

1. Given an encoded string, you have to output the decoded string. The encoded string will have the following format: 1[ac2[de]], 2[a2[b3]], 3[a3[b23c1[d]k2[x]]]. Basically, a string consists of alphabets, numbers, and square brackets. Before each square bracket, there will be a sequence of numbers. The sequence of numbers represents how many times they have to be repeated in the resultant string. See example for better understanding.
1.

```Example:

Input: 1[ac2[de]]
Output: acdede
Explanation: 2[de] means "de" should be
repeated two times and 1[ac....] means
whatever was the resultant string between
the square brackets should be repeated only once.

Input: 2[a4[b]c13d2[e]]
Output: abbbbc13deeabbbbc13dee
Explanation: As you can see, the decoded
string may also contain digits because those digits
are not followed by a square bracket in the encoded string.

Input: 1[a2[b1[c11[d]]]]
Output: abcdddddddddddbcddddddddddd
Explaination: This example shows that there
can be multiple digits before a square bracket(11 in
this case)```

I was able to solve the question using recursion with a little bit of debugging. The interviewer then asked me to run my code and tested against a few test cases. (Best solution for this problem is to use stack)

After one hour, I got a call for the next interview round.

Technical Round 2(45 minutes): There were two interviewers for this round and it was based on class design. The interview was again conducted on the CodeSignal platform. After the introduction, they started with the question.

1. Design a leaderboard that supports the following functionalities: 1. addUser() – the ability to add new Users with the attribute name, email, and score. The initial score should be zero.  2. updateScore() – the ability to update the score of a user with the given value.  3. getRank() – the ability to get the rank of the given user. If two users have the same score, then the user who was added before will have a better rank(i.e. lower value).  4. getFirstK() – the ability to get the list of users with rank less than equal to K.

I created two classes and gave the brute-force approach for all the functions. Then, the interviewers told me the expected time complexity for each of the functions. After some time and hints, I told them an approach that uses BST and also modified the classes that I created. We discussed the approach in detail and the time complexity for each function. After this, we were short on time, so the interviewers told me to assume certain functions and complete my code.

After 15 mins, I got a call for the HR round.

HR Round(1 hr): This was a very long HR round. Here are some of the questions:

1. Introduce yourself
2. Explain your final year project(FYP)
3. What did you learn from this project?
4. How will you explain your project to a layman?
5. What are the use-cases of your project?
6. Few project-related questions
7. What are the problems faced during the project and how did you solve them?
9. What are the things that you didn’t like about the internship?
10. What did you learn from your internship?
12. What are the technologies you used in your project?
13. Some internship project-related questions.
14. Do you remember the questions from your online round? Explain to me the first question?
15. What do you expect from a company?
17. What was the third question and how did you solve it?

After this, he asked me a coding question.

1. Given a string S containing digits. Find the number of valid IP addresses that can be formed from the given string.
Constraints: 1 <= length(S) <= 12

```Example:
Input: 11111111111
Output: 4
Explaination:
These are the valid IP addresses
111.111.111.11
111.111.11.111
11.111.111.111
111.11.111.111```
1. I first explained my solution and then implemented it. He gave me few test cases to run and I got correct answers.

After this, the interviewer asked me if I had any questions for him. I asked how uber was affected by the pandemic. After his reply, the interview ended.

I got a call after two days that I was selected.

Verdict: Selected!

All the best everyone!

My Personal Notes arrow_drop_up
Recommended Articles
Page :