## Recent Interview Questions

- 0of 0 votes
Suppose there are N number of clusters, B number of machines and number of tasks in clusters are stored in an array named a. The goal is to minimize the single most overloaded machine and every cluster must be given at least one machine. Output should be one integer representing the number of the tasks in the busiest machine (rounded up).

1<=N<=500000

N<=B<=2000000

1<=ai<=5000000

for example, N=2,B=7, a=[200,450], output should be 100.

Any ideas?

Thanks

- 0of 0 votes
4/5 Round at Uber

Coding: Given a 2D array of either '\' or '/', find out how many pieces this rectangle is divided into graphically.

For a 2X2 matrix with

/\

\/

The matrix split into 5 pieces - the diamond in middle and the four corners. Return 5 as the answer.

5/5 Round at Uber

Design Excel.

- 0of 0 votes
2/5 Round at Uber

Bar raiser - Behavioral questions. Coding: Find if a set of meetings overlap. Meeting has a starttime and an endtime with accuracy to minute. All meetings take place in the same day. Do this in O(n) time.

3/5 Round at Uber

Coding: Subset sum. Follow-up: Optimize the solution.

- 0of 0 votes
1/5 Round at Uber

Manager : Behavioral questions. Basic system design concepts. Publish/subscribe model. Discussion on Uber architecture.

- 0of 0 votes
I've got these trees of integers; they're like regular trees, but they can share nodes.

I need to know if any branch of this tree sums to 100.

7

/ \

8 6

/ \ / \

2 3 9

/ \ / \ / \

5 4 1 100

Follow up question was how would you change the code to handle negative numbers

- 0of 0 votes
I've got these trees of integers; they're like regular trees, but they can share nodes.

I need to know if any branch of this tree sums to 100.

7

/ \

8 6

/ \ / \

2 3 9

/ \ / \ / \

5 4 1 100

Follow up question was how would you change the code to handle negative numbers.

- 0of 0 votes
Find distance between any two nodes of binary tree and binary search tree.

- 0of 0 votes
Design and implement a Version-Queue. A Version-Queue maintains a version number along with normal Queue functionality. Every operation[Enqueue/Dequeue] on the Queue increments its version.

Implement the following functions:

1. Enqueue - appends an element at the end of the queue.

2. Dequeue - returns the top element of the queue.

3. Print - it takes a version number as input and prints the elements of the queue of the given version. The version number input can also be an old/historical version number. E.g. if the current version number of the queue is 7 and the input to this function is 5, then it should print the elements of the queue when its version number was 5.

For simplicity, assume the elements are integers.

Input format:

First line should have an integer n (number of operations). This should be followed by n number of lines, each denoting one operation.

e.g.

6

e 1

e 4

d

e 5

p 2

p 4

'e' stands for enqueue, 'd' stands for dequeue and 'p' stands for print.

- 0of 0 votes
There is a conference room. N people are joining the conference. You have the start time and end time of each of them visiting it. You are asked to determine the maximum number of people that can be inside the room.

Example – Four people are visiting the conference

Person A B C D

Start (hour) 1 3 2 5

End (hour) 4 5 7 10

Answer will be – 3

- 1of 1 vote
Uber

1. Mirror Binary Tree

2. String pattern matching

The matching should cover the entire input string (not partial).

The function prototype should be:

bool isMatch(String str, String pattern)

Some examples:

isMatch("aa","a") → false

isMatch("aa","aa") → true

isMatch("aaa","aa") → false

isMatch("aa","a{1,3}") → true

isMatch("aaa","a{1,3}") → false

isMatch("ab","a{1,3}b{1,3}") → true

isMatch("abc","a{1,3}b{1,3}c") → true

isMatch("abbc","a{1,3}b{1,2}c") → false

isMatch("acbac","a{1,3}b{1,3}c") → false

isMatch("abcc","a{1,3}b{1,3}cc{1,3}") → true

In pattern string, a char followed by {lower, upper} means that the char occur lower to upper(exclusive) times. e.g. a{1, 3} -> a occurs 1 or 2 times.

- 0of 0 votes
given a list of numbers, put with + - * / any two number, find the maximum value you can get.

int getMaxNumber(int[] nums){

}

- 0of 0 votes
You have a long string that contains of 0's and 1's, seprated with some delimiter (like "!"). the number of delimeters after each 0 or 1 is between 1 to 3.

for example a string such as 0! 1!!! 0!! 1!! 0! 1! 0!!! 1!! 0!! (and so on...)

Take this long string and convert it to a 7 digits number by some porgramming algorythem,

(you can use every lanugage you want)

- 0of 0 votes
Given a group of movies and their start time, assuming that are 1 hour long,

Returns a movie schedule (no time conflict).

enter:

Movie ("Shining", [14, 15, 16])

Movie ("kill bill", [14, 15])

Movie ("Pulp fiction", [14, 15])

One possible result is shining 16, kill bill 15, pulp fiction 14

public void schedule (HashMap <String, List <Integer >> map) {

}

- 2of 2 votes
3.1 design: design fb inbox search —> just focus on the post

4.1 binary tree to circular double linked list.

4.2 two arrays, find the common elements of two sorted array. if one array is small, the other is very big.

- 1of 1 vote
2.1 career discussion

2.2 divide two numbers with no / or %

- 2of 2 votes
1/4 round of FB on-site interview, Master Degree, Hired

1.1 diameter of tree

1.2 find the point which have the maximum overlap of intervals

- 0of 0 votes
Write test cases for widgets which pop out when you do Google Search. For e.g, tan x, convert 60kgs to pounds etc. You don't have to necessarily go into details of individual widget testing but more general scenarios testing this functionality of invoking widgets via the search toolbar

- 0of 0 votes
friend circle. Given a streaming pairs representing friend relationship

(1, 2) means 1 and 2 are friends, (1, 3) means 1 and 3 are friends

Return all its friends.

List<Integer> getFriends (Iterator<List<Integer>> relations, int id){

}

- 0of 0 votes
A company's organizational structure is represented as

1: 2, 3, 4

In the above employees with id 2, 3 and 4 report to 1

Assume the following hierarchy.

1: 2, 3, 4

3: 5, 6, 7

5: 8, 9, 10

Given an employee Id, return all the employees reporting to him directly or indirectly

- 0of 0 votes
For given list of numbers find out triplets with sum 0

Input : arr[] = {0, -1, 2, -3, 1}

Output : 0 -1 1

2 -3 1

- 0of 0 votes
Given a String and dictionary of words, break the string in minimum space sentence.

Ex:

inputStr = "ilikefacebook"

dictionary = {"i","like","face","book","facebook"}

Possible Strings:

i like face book - 3 spaces

i like Facebook - 2 spaces - this is expected answer.

- 0of 0 votes
What will be the output on single core machine? Does worker 1 will keep on printing or two thread keeps on context switching among themselves.

`import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class SimpleThreadPool { static class WorkerThread implements Runnable { private String command; public WorkerThread(String s){ this.command=s; } @Override public void run() { while(true){ System.out.println(Thread.currentThread().getName()+" Start. Command = "+command); } } private void processCommand() { try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } } @Override public String toString(){ return this.command; } } public static void main(String[] args) { ExecutorService executor = Executors.newFixedThreadPool(2); executor.execute(new WorkerThread("Worker Thread 1")); executor.execute(new WorkerThread("Worker Thread 2")); executor.shutdown(); while (!executor.isTerminated()) { } System.out.println("Finished all threads"); } }`

- 0of 0 votes
given a matrix and a target, return if there is a path who’s sum is == target

Input: matrix, integer output: true or false;

- 0of 0 votes
permute the String including case change

"abc".

For example:

abc

ABC

Abc

aBc

abC

ABc

abC

AbC

- 0of 0 votes
implemnt JSON.stringify()

- 0of 0 votes
Phone interview question from January.

We have a maze with three types of spaces:

1. Walls

2. Offices

3. Hallway space

Given a maze, determine which non-wall space would minimize the sum of all distances between that space and every office. You can only move up, down, left, and right.

(Edit: ChrisK described the problem more clearly than I did: "find the field that minimizes the sum of the shortest path[s] from this field to each office space.")

Example:`WWWWWWWW WWW O WW WWW OW WWW WWWW WO WWWW WWW WWWW WO W WWWWWWWW`

O = office, W = wall, spaces are hallway spaces

You can represent the maze however you want. That is, you can use any data structures you want, and you don't necessarily have to use O for office, W for Wall, and spaces for hallways.

(I'm not sure if you can actually start from an office space, but that should be a trivial issue because you can always just start a position adjacent to an office.)

- 0of 0 votes
Can you achieve the following without using enums? Given the last two lines stay the same.

`enum DayHalf { AM,PM; DayHalf dh1=DayHalf.AM; DayHalf dh2=DayHalf.PM; }`

- 3of 3 votes
1 year exp. Interviewed at Cambridge, MA

Round1

LC304. Follow-up: given a char stream instead a string as the input, get the longest substring with at most K distinct characters.

Round2

Find out the area of a number of squares on a plane, an advanced version of LC223.

Had no clue on that problem at all so the interviewer kindly gave another one LC305.

Round3

Similar to LC393 but the interviewer made a slightly different rule for encoding.

Follow-up: decode with utf-16. It took quite a while for me to understand the rules.

Round4

Card game rule: the hand is drawn from a pack of cards (no jokers).

Play cards ONLY when they are

1. 3 of a kind ('AAA' ) or 4 of a kind('AAAA’).

2. a straight flush of 3 or more cards('JQK' or 'A23456...' in the same suit).

Find out whether the player is able to play the whole hand given.

e.g. [Spade A, Spade K, Spade Q, Diamond Q, Heart Q] return false.

[Spade A, Spade K, Spade Q, Diamond Q, Heart Q, Club Q] return true.

- 0of 0 votes
you are given N (1<=N<=20000) squares on X-Y plane. Your task is to find the area which is

common to all the squares (Area of intersection of all the squares)

Input

First line contain T the number of test cases. Then T test cases follow. First line of each test case

contains N, the number of squares Each of following N line contains 3 integer (X, Y, L) cordinate

of lower left vertex and size of the square.

-10^9<=X,Y<=10^9 1<=L<=10^9 for java code

- 0of 0 votes
Youmob social bookmarking site

Youmob is fastest social bookmarking service without any registration. Youmob is one of the best ad posting and social bookmarking website.

www.youmob.xyz