⏱ 0:01est. 23 min
Uber
// Leetcode's Serialize and Deserialize BST
// https://leetcode.com/problems/serialize-and-deserialize-bst/
// - Technical screening (Code challenge to make sure you can write code)
// - DS & Algo coding round
// - JS coding round
// - System design round
// - Hiring manager round
// - Bar raiser
// Twitter Design
// Knapsack problem with a twist that you can take any number of sacks of a given weight.
// Given a set of nodes, find if a Binary tree could be made out of it. All the nodes has to be used.
// Do you have experiences with micro-services?
// Implement a throttler that executes an array of tasks. When the throttler is passed a number, only execute that number of the tasks and passes the other tasks into a queue.
function throttler(tasks = [], num = 0) {
for (const task of tasks) {
if (num == 0) {
task();
} else {
setTimeout(task, 0);
}
}
}
function print(i) {
console.log(i);
}
throttler(
[
print.bind(null, 1),
print.bind(null, 2),
print.bind(null, 4),
print.bind(null, 6),
],
2
);
// System design - talk through front-end architecture and design (2x of these). Also, general front-end specific questions (like how do browsers work and questions around libraries)
// Algorithms - similar to Leetcode questions. I didn't do well here, there was only one way to solve the problem and I didn't get it.
// Coding - build a practical front-end component using HTML/CSS and vanilla JavaScript. Know: event listeners, parsing user supplied data, DOM work, getting data in the view, etc. No trickiness or algos here.
// When you run into Javascript performance issues, what steps do you take?
// Why Uber?
/**
1. Implement a loading bar that animates from 0 to 100% in 3 seconds
2. Start loading bar animation upon a button click
3. Queue multiple loading bars if the button is clicked more than once. Loading bar N starts animating with loading bar N-1 is done animating.
*/
// Implement a search tree in language of your choice and add various optimizations.
// Graph and string related algo problems.
// What is the most challenging technical problem you have had?
// Why do you want to work at Uber?
// Spending 15 minutes to descript something to me.
// Design an error reporting service.
// The architecture interviews to design an Instagram system and a job-processing queue system
// Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
// Leetcode for technical rounds should be enough. For design definitely concentrate on DB. They go into a lot of details.
// NxN square puzzle is made of 2x2 matrix blocks that contain integer. Two block match when they have the same numbers on the edge. Code how to solve the puzzle. It's guaranteed there is one and unique solution.
// One of the questions: For a linked list with pointers to next node and another random node, make a deep copy of the linked list.
/**
* 1. Given a string of a's and b's return if all a's occur before all b's .
Example:
--> aabb return true
--> a return true
--> b return true
--> aaba return false
--> abab return false
2. We are given a list of alpha numeic Events and we need to check if it is sorted or not ?
An event can either contain a letter (alpha), an hyphen '-' (should be considered as alpha and not negative) or a number.
All the alpha(including '-') should be sorted before number.
Two alpha should be sorted in natural order
Series of numbers should be collected and compared like abc123 and abc456 is in sorted order because 123 < 456
If two numbers are same value, one with smaller length should be sorted first.
Ensure handle number correctly like abc122axy99z have two numbers 122 and 99. Also number can be padded wuth zeroes. if two numbers are same value, one with smaller length should be sorted first.
Example sorting order:
abc is sorted before 123
123 is sorted before 456
954 is sorted before 01234
abz is sorted before axy
Test Input:
["abc123hij-k","abc123hij-k","abc456hij-k","abc954hij-k","abc01234hij-k","xyz123hij-k","x123hij-k","21030003020"]
Test Output:
true
*/
// Given a matrix of inaccessible cells and diamonds, write an algorithm that starts in top left, goes to bottom right, and then back to top left
// Implement mine sweeper game.
// Design a simplified version of LinkedIn
// System design for a dating app like Tinder
// Find the anagrams in the list of strings.
// Design a twitter system
// Implement RateLimiting algorithm.
// Calculate the bounding box for a series of connected components
// implement 8queue
// What is Single responsibility use case in day to day life?
// What is meaning of Open/Closed principle ?
// Find the longest palindrome substring in given string
// Implement a variation of heap sort.
// Implement a calculator.
// Flood Fill Algorithm.
// Math generate numbers coding question
// 1. System design - Google Search AutoComplete
// 2. Coding- Give a very big list of number of colors(not fit for memory). Write function that randomly show color based on percentage of color
// 3. in old miner game, based on given size n, auto created a miner board. following show all adjacent zero ce
// The typical 3 Programming questions, 1 Architecture question. A lot of tree based questions.
// Find a needle in haystack. all permutations.
// Graph traversal discussion. Given a dependency graph - propose execution order.
// Parking lot design system.
/*
Given two async streams -
Trip : {tripId, date, city}
Bill: {billId, tripId, date, amount}
Design a system to get real time aggregated view of following nature
City, TripCount, TotalAmount
Events in both streams can be out of sync or duplicate. But result needs to be accurate and realtime.
*/
// Design a system like Twitter/Facebook/WhatsApp/Pinterest etc.
// Design an app that suggests the closes bus stop with earliest bus connection.
// Phone keyboard number to word mapping; Time interval/calendar meeting time slot operations; stock trading system design.
/*
You are given a binary tree in which each node contains an integer value.List all paths that sum to a given target value.
The path does not need to start or end at the root or a leaf, but it must go downwards (traveling only from parent nodes to child nodes).
*/
// Design uber heatmap
// Given a string input, create a function that will output a compressed version of the string. E.g. Input = "AAABBZZDDD", Output = "A3B2Z2D3"
// Develop a mobile client for Flickr
// LRU cache
/*
#1: code a music player interface which stores a playlist and supports play, pause, stop, next/prev track, how do you handle errors from h/w. had to code all the classes and how messages worked were exchanged between them and justify my choices.
#2: design a csv parse when string has double quotes and newlines. return result of parsing as list<list<string>> with one list per line. when you have a substring within double quotes, you have to ignore commas within double quotes for eg.,
"a, b, \"hello,world\", xy\ne,f,g" should return
a#b#hello,world#xy
e# f# g
#3: design a image sharing application like instagram (how do you handle traffic spikes, how to handle storage, retrieval, publish to follower feed, caching etc.,)
#4: there was a bar raiser interview who asked me to describe how I scaled the graph DB per my resume
#5: manager asked behavioral qns like why uber, how do you mentor junior employees, talk about a scenario when you took a risk and it either failed/succeeded, what is your ideal job etc.,
the first two I had to write, compile and pass their unit tests on coderpad. I could choose the language of choice (c++, java, python etc.,) #3 was just white-boarding.
*/
// Multiply 2 long numbers without using multiplication.
/*
Given an english sentence how can you tell if it is valid or not.
For Eg.
"Iworkatuber" is a valid sentence
"Iworkatasdf" is an invalid sentence.
*/
// What are features you would add to Uber?
// Implement a GridView of Images from Flickr's API
// Time traveling hash map
// Topological Sort
// Phone screen: Given a stream of events, bucket them into buckets of a given time window (phone screen). Also had a derivative of the TwoSum question and a Knapsack problem in disguise as something else.
// What is a Consistency (in CAP theorem)? Is Paxos consistent protocol?
// Write abstract http client with back-off support?
// How can be a HashMap made concurrent / thread safe?
// Sketch an architecture for Snapchat.
// Design a large scale web-based SoA for mobile clients with location awareness (e.g.: Uber, bike sharing, etc)
// Self-evaluation question: The question is when companies will realize the current hiring process has came to exhaustion?
// How to recognize whether it is a banana or apple in a image.
// Implement a short URL server
// Design a real-time service architecture
// Given output X write a program to produce said output given an environment of Y
// The interview was coding a simple HTML parser.
// Create custom reduce and map function in javascript.
// https://betterprogramming.pub/rewrite-your-own-array-methods-foreach-map-filter-find-reduce-1718e1138c3e
const myForeach = function (array, callback) {
for (let i = 0; i < array.length; i++) {
callback(array[i], i, array);
}
};
Array.prototype.myForeach = function (callback) {
//this keyword reference to the array itself
for (let i = 0; i < this.length; i++) {
callback(this[i], i, this);
}
};
Array.prototype.myMap = function (callback) {
let newArray = [];
for (let i = 0; i < this.length; i++) {
let newMappedItem = callback(this[i], i, this);
newArray.push(newMappedItem);
}
return newArray;
};
Array.prototype.myFind = function (callback) {
let result;
for (let i = 0; i < this.length; i++) {
let isFound = callback(this[i], i, this);
if (isFound) {
result = this[i];
break; //stop the loop if find that item
}
}
return result;
};
Array.prototype.myReduce = function (callback, initialValue) {
for (let i = 0; i < this.length; i++) {
initialValue = callback(initialValue, this[i], i, this);
}
return initialValue;
};
// If user input a name in input, You have to highlight the chemical element if it consist in his name.
// eg. If input name is "Casper" Then highlight "Ca".
// Implement a Timer (with three buttons: start, stop, reset) by HTML and JavaScript.
// Find and replace a set of substrings within a string. (javascript)
// https://www.glassdoor.co.in/Interview/Uber-Front-End-Developer-Interview-Questions-EI_IE575263.0,4_KO5,24.htm
/*
Interview
1 online assessment on CodeSignal
3 interviews online(2 coding interviews 1 general taking about the previous experience)
In total spent 1 month, OA consists of 3 code problems(2 easy 1 medium) and 7 choice question following(basic CS knowledge)
Interview Questions
first coding problem minesweeper
The second coding problem is to design a hashmap
pass the first one and almost got the second one
the interviewees are really friendly and willing to guide you
*/
/*
Online Coding round had 2 questions.
1. A variation of Sliding window, to find max of all the window min fro the array.
2. An application of Binary search.
*/
/*
Implement a logger
Coding questions related to two points on a 2D grid
Twitter design
*/
/*
Implement a search tree in language of your choice and add various optimizations.
*/
/*
The coding interviews were related to the domain of the Uber Sofia site and relied on data structures. The architecture interviews to design an Instagram system and a job-processing queue system. Non-engineering questions were mostly related to background, process and motivation.
*/
/*
The prep material for the test is as follows:
Task 1: This focuses on working with numbers, basic string manipulation, and basic array manipulation and requires a combination of 2-3 of these concepts. Requires 5-10 lines of code and the average time for solving this task should be 10 minutes.
- Task 2: The focus is the same as the 1st task but with slightly more complex implementation and requires a combination of 3 to 5 the above-mentioned concepts. The solution typically requires writing 10-20 lines of code and the average time for solving this task should be 15 mins.
- Task 3: In addition to the knowledge demonstrated previously, this task will involve splitting a task into smaller subtasks/functions, manipulating two-dimensional arrays, and using hashmaps. You may be required to write 25-40 lines of code and the average time for solving this task should be 20 mins.
- Task 4: In addition to the knowledge demonstrated previously, this task will involve working with trees, understanding hashmaps, fundamentals of discrete mathematics, and brute-force search. You may be required to write 20-35 lines of code and the average time for solving this task should be 25 mins.The prep material for the test is as follows:
Task 1: This focuses on working with numbers, basic string manipulation, and basic array manipulation and requires a combination of 2-3 of these concepts. Requires 5-10 lines of code and the average time for solving this task should be 10 minutes.
- Task 2: The focus is the same as the 1st task but with slightly more complex implementation and requires a combination of 3 to 5 the above-mentioned concepts. The solution typically requires writing 10-20 lines of code and the average time for solving this task should be 15 mins.
- Task 3: In addition to the knowledge demonstrated previously, this task will involve splitting a task into smaller subtasks/functions, manipulating two-dimensional arrays, and using hashmaps. You may be required to write 25-40 lines of code and the average time for solving this task should be 20 mins.
- Task 4: In addition to the knowledge demonstrated previously, this task will involve working with trees, understanding hashmaps, fundamentals of discrete mathematics, and brute-force search. You may be required to write 20-35 lines of code and the average time for solving this task should be 25 mins.
*/
/*
https://leetcode.com/discuss/interview-question/836679/uber-online-assessment-sept-2020
The Online assessment test was held on codesignal.
Q1. Given two arrays A[] and B[] containing positive integers and an integer 'd'.
we need to return the count of elements,A[i], in A[] that satisfies below condition
| A[i] - B[j] | > d (0<=j<n where n is size of B).
e.g.
Input : A = [7, 6, 9] B = [13, 1, 4] and d = 3
Output : 1
Explanation : For A[i] = 7, Difference | A[i] - B[j] | is greater than d for B[j] = 13, 1 but equal to 3 for B[j] = 4. Hence, 7 does not qualify.
Similary for 6, the differences are [7, 5, 2]. since 2 is less equal to 3 hence this element does not qualify as well.
Whereas for 9, the differences are [4, 8, 5]. here difference with each element of B is greater than d. So we have found 1 such element.
So the output would be 1.
Q2. Given an array A[] of integers and an integer m representing the size of sub-array.
We need to return maximum among the minimum elements of m-size sub arrays in A.
*/
/*
https://leetcode.com/discuss/interview-question/1272223/UBER-OA-Questions-codesignal-test-2021
Ques 1 : given 2 string s , t we have to find kth character from the string formed by following process lets say x = ""
i = 1 append s to x 1 time
i = 2 append t to x 2 times
i = 3 append s to x 3 times
i = 4 append t to x 4 times
i = 5 append s to x 5 times
and so on
you are given k <= 10^16, you have to find kth character from x formed using above process.
eg: s = "a", t = "bc", k = 4 ---> given input
Output: b
(since string x = "abcbcaaabcbcbcbc..... 4th char is b)
Ques 2 : given a, b, c, d we have to find
sum = 0;
for(int i=a; i<=b; ++i) {
for(int j=c; j<=d; ++j) {
sum += (i^j);
}
}
return sum
we have to optimize this, This code was given in question itself.
eg: a = 2, b = 3, c = 7, d = 8 --> given input
output : 30
final ans is --> (2^7) + (2^8) + (3^7) + (3^8) = 5 + 10 + 4 + 11 = 30
*/
/*
A --|
|-- D --|
B --| |-- E
|
C --|
*/
// Write a scheduler in JavaScript that accepts max number of concurrent tasks as a parameter and schedules tasks (each task may take arbitrary time to complete
// runTasks(tasks, allDoneCallback)
let tasks = [
{
id: "A",
isDone: false,
method: (cb) => {
setTimeout(function () {
this.isDone = true;
// cb("A");
}, 500);
},
},
];
function allDoneCallback() {
console.log("done");
console.log(tasks);
}
function checkIncompleteTasks(taskName, cb) {
console.log("taskName", taskName);
tasks.map((t) => {
if (t.id == taskName) {
t.isDone = true;
}
});
runTasks(
tasks.filter((t) => !t.isDone),
cb
);
}
function runTasks(tasks, cb) {
tasks.map(function (t) {
t.method(checkIncompleteTasks, cb);
});
cb();
}
runTasks(tasks, allDoneCallback);