## Recent Interview Questions

- 0of 0 votes
You are given an old touch smartphone numbers having dial pad and calculator app.

Aim: The goal is to type a number on dialpad.

But as phone is old, some of the numbers and some operations can't be touched.

For eg. 2,3,5,9 keys are not responding , i.e you cannot use them

But you can always make a number using other numbers and operations in Calculator. There could be multiple ways of making a number

.Calculator have 1-9 and +,-,*,/,= as operations. Once you have made the number in Calculator you can copy the number and use it.

You have to find minimum number to touches required to obtain a number.

#Input:#

There will be multiple Test cases .Each test case will consist of 4 lines

1) First line will consist of N,M,O

N: no of keys working in Dialpad (out of 0,1,2,3,4,5,6,7,8,9)

M:types of operations supported (+,-,*,/)

O: Max no of touches allowed

2) second line of input contains the digits that are working e.g 0,2,3,4,6.

3) Third line contains the valued describing operations, 1(+),2(-),3(*),4(/)

4) fourth line contains the number that we want to make .

#Output:#

Output contains 1 line printing the number of touches required to make the number

#Sample Test Case:#

1 // No of test cases

5 3 5 // N ,M, O

1 2 4 6 0 // digits that are working (total number of digits = N),

1 2 3 // describing operations allowed (1--> '+', 2--> '-', 3--> '*' , 4--> '/' )(total number is equals to M)

5 // number we want to make

Answer 3

How 4? 1+4= , "=" is also counted as a touch

2nd Sample Case

3 // No of Test cases

6 4 5 // N ,M, O

1 2 4 6 9 8 // digits that are working (total number of digits = N),

1 2 3 4 // describing operations allowed (1--> +, 2--> -, 3--> , 4-->/)

91 // number we want to make

6 2 4 // 2nd test case

0 1 3 5 7 9

1 2 4 // +, -, / allowed here

28

5 2 10

1 2 6 7 8

2 3 // -, allowed

981

#Output:#

2 // 91 can be made by directly entering 91 as 1,9 digits are working, so only 2 operations

5// 35-7=, other ways are 1+3*7=

9//62*16-11=

Order for computation will be followed as symbols entered, if + comes, it will be computed first

One more example: lets say 1,4,6,7,8,9 works and +,-,* works.

2,3,5 and / doesn't work.

If you have to type 18-> 2 operations. (Each touch is considered an operation),br> If you have to type 5 -> '1+4=' that requires 4 operations. There could be other ways to make '5'.

- 0of 0 votes
Given a n-nery tree and its deep copy, a node in the original tree, return the corresponding node in the copy

public TreeNode getCopyNode(TreeNode root, TreeNode copy, TreeNode node)

- 2of 2 votes
Apple phone interview

Given an API to find all IPv4 addresses in a log file, find all IPs that occurred only once.

Follow-up: What if the log comes from a data stream.

Follow-up: If the machine has 4GB RAM, is there going to be a problem?

- 0of 0 votes
write bash code to determine if the first number in the string is greater than 1000

STR="count ------- 43952 (1 rows)"

- 0of 0 votes
Complete the puzzle which simulates generic directory structures.

* The solution should be directory agnostic.

* Be succinct yet readable. You should not exceed more than 200 lines.

* Consider adding comments and asserts to help the understading.

* Code can be compiled with javac Directory.java

* Code should be executed as: java -ea Directory (-ea option it's to enabled the assert)

*/

/**

* change the code here.

*/

class Shell {

Shell cd(final String path) {

return this;

}

public String path() {

return "/";

}

}

public class Directory {

public static void main(String[] args) {

final Shell shell = new Shell();

assert shell.path().equals("/");

shell.cd("/");

assert shell.path().equals("/");

shell.cd("usr/..");

assert shell.path().equals("/");

shell.cd("usr").cd("local");

shell.cd("../local").cd("./");

assert shell.path().equals("/usr/local");

shell.cd("..");

assert shell.path().equals("/usr");

shell.cd("//lib///");

assert shell.path().equals("/lib");

}

}

- 0of 0 votes
I have a Amazon Phone interview for sr. business analyst They provided a collabedit link for the interview stating that we may ask Basic programming and SQL questions.

Can someone having this experience from past help me understand what kind of questions I can expect. I honestly am a BA, PM professional with not a lot of exposure to coding or SQL. Some guidance will help me prepare better. Are the questions asked in SQL basic or quite intricate? Please advise

- 0of 0 votes
The memmove() function copies n bytes from memory area src to memory area dest. The memory areas may overlap: copying takes place as though the bytes in src are first copied into a temporary array that does not overlap src or dest, and the bytes are then copied from the temporary array to dest.

- 0of 0 votes
Write the code to find the median of an unsorted array in average linear time.

followup the array is distributed across many machines.

- 0of 0 votes
Write a function to split a SQL query into individual statements.

give you a String which contains a separate Query with a semicolon ";" return all valid queries

Such as

"select name from courseinfo ;; select * from db1 where home = 'usa' ;"

The main thing to consider is that some special cases such as the escape symbol and the quotation marks inside the semicolon

public List<String> getQuery(String queries){

}

- 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

- 1of 1 vote
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
Red black trees versus AVL trees. Which one is better ?

- 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

- 2of 2 votes
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.