📜 ⬆️ ⬇️

Issue # 2: IT training - current issues and challenges from leading companies

This week we will publish a selection of the tasks and questions that Uber gives during interviews. Tasks picked up various levels of complexity from “Easy” to “Hard” to make it interesting for everyone. The condition is given in English.

Answers, as well as last time, will be published within a week. Cool if you write your own solutions in the comments)

Questions:
')
1. What KPIs would you use if you launched a new Uber service in a certain part of the world and wanted to know how successful it is?

2. What project you were working on failed? Could you do something to prevent it from failing?

Tasks:

one.
Push, pop, top, and retrieving the bottom element in constant time.

push (x) - Push element x onto stack.
pop () - Removes the element.
top () - Get the top element.
getMin () - Retrieve the minimum element in the stack.

Example:

MinStack minStack = new MinStack(); minStack.push(-2); minStack.push(0); minStack.push(-3); minStack.getMin(); --> Returns -3. minStack.pop(); minStack.top(); --> Returns 0. minStack.getMin(); --> Returns -2. 

2
O (1) time.
insert (val): inserts an item val to the set if not already present.
remove (val): remove the item from the set if present.
getRandom: Returns a random element from the current set of elements. Each element must have been returned.

Example:

 // Init an empty set. RandomizedSet randomSet = new RandomizedSet(); // Inserts 1 to the set. Returns true as 1 was inserted successfully. randomSet.insert(1); // Returns false as 2 does not exist in the set. randomSet.remove(2); // Inserts 2 to the set, returns true. Set now contains [1,2]. randomSet.insert(2); // getRandom should return either 1 or 2 randomly. randomSet.getRandom(); // Removes 1 from the set, returns true. Set now contains [2]. randomSet.remove(1); // 2 was already in the set, so return false. randomSet.insert(2); // Since 2 is the only number in the set, getRandom always return 2. randomSet.getRandom(); 

3
It is a process that can be carried out at the same time or the computer environment.
Design a binary tree. There is no restriction on how your serialization / deserialization algorithm should work. This can be deserialized to the original tree structure.
For example, you may serialize the following tree
one
/ \
2 3
/ \
4 5
as "[1,2,3, null, null, 4,5]", serializes a binary tree. You must be creative and come up with different approaches.
Note: Do not use a class member to store states. Your serialize and deserialize algorithms should not be stateless.

Source: https://habr.com/ru/post/329208/


All Articles