## Recent Interview Questions

- 1of 1 vote
Print the bottom view of a Binary Tree.

ex-`1 2 3 4 5 7 8 9 10`

result is 4, 8, 5, 9, 7, 10

- 0of 0 votes
Given an alphabet where we do not know the order of the letters also do not know the number of letters.

We are give an input list of tuples where each entry in the list gives an ordering between the 2 letters

Determine the alphabet order.

Ex-

<A, B>

<C, D>

<C, E>

<D, E>

<A, C>

<B, C>

Order is A, B, C, D, E

- 0of 0 votes
I was asked this question in a recent interview for a startup.

We have coffee vending machine with 3 buttons which can dispense 4oz, 7oz and 13oz of coffee.

Given a cup and the min and max amount(oz) of coffee it should fill. determine if the coffee vending machine can satisfy the condition.

The buttons can be pressed as many times as possible to fill the cup. Coffee shouldn't overflow..

- 2of 2 votes
AWS phone interview

Find the left view of binary tree

1

/ \

2 3

/\ \

4 5 6

/ /

7 8

/

9

return [1, 2, 4, 7, 9]

- 1of 1 vote
Given a number, rearrange the digits of that number to make a higher number, among all such permutations that are greater,one of them is the smallest, Find the smallest greater permutation (the next Permutation).

Examples:

next_permutation (12) = 21

next_permutation (315) = 351

next_permutation (583) = 835

next_permutation (12389) = 12398

next_permutation (34722641) = 34724126

- 0of 0 votes
Given as list of movies in a csv file, extract the movie name and genre and be able to return a query based on the years and the genre.

Basically, Parsing a CSV input file and build an indexed data storage to allow search the data in time manner.

- 0of 0 votes
Given a list of tasks each with memory requirements and time, only one machine has K memory.

Do not consider the context switch, page swap, virtual memory, (for example, the machine has only 20mb memory, a task that requires 25MB of the task can only wait until there is enough memory to run it.) The running task cannot be suspended.

Ask how long it takes to complete all these tasks. . .

- 0of 0 votes
QuickBooksCustomerHelp.org is a third party QuickBooks Support providers over their toll free QuickBooks Technical Support. Experts team is present here 24x7 to help users. This QuickBooks Customer Service Helpline provides best possible solutions to the users of QB Accounting Software.

- 0of 0 votes
First common Ancestor of Binary tree . Java Solution needed.

Class Node {

Node Parent;

Node LeftChild;

Node rightChild;

int val;

}

publlic Node firstAncestor(Node leftNode, Node rightNode){

// We don't get the root node here. From left and right child we need to find it's parent and find the lowest common ancestor.

}

- -2of 2 votes
If b == “1”:

quit()

- 0of 0 votes
1) You sell roses. Each rose cost 30 cents to buy and you can sell them for $10 a dozen.

a) How many you need to sale to break even if you bought 600 roses?

b) Tomorrow is holiday - there's 20% likelihood you will sale 600 roses, 50% likelihood of selling 900 roses and 30% likelihood of selling 1200 roses. How many would you buy to maximize profit?

- 1of 1 vote
Write a method that can take in an unordered list of airport pairs visited during a trip, and return the list in order:

Unordered: ("ITO", "KOA"), ("ANC", "SEA"), ("LGA", "CDG"), ("KOA", "LGA"), ("PDX", "ITO"), ("SEA", "PDX")

Ordered: ("ANC", "SEA"), ("SEA", "PDX"), ("PDX", "ITO"), ("ITO", "KOA"), ("KOA", "LGA"), ("LGA", "CDG")

- -1of 1 vote
how do i update my Garmin maps for free? Dial +61-1800-215-732

- 0of 0 votes
Given a binary tree, where each node represents an integer, find the max value of path sum.

- 2of 2 votes
April Google Interview 1/4

A = a+b-c-a-b-c-a-b (Tree)

B = b+a+c+a+b-c+b (Tree)

is A equal to B

- 3of 3 votes
April Google Interview 4/4

Build HTML Reverser

Given

<A>(hello)(<P>ab</P>)(<S>hi</S>)</A>

Return

<A>(<S>ih</S>)(<P>ba</P>)(olleh)</A>

- 2of 2 votes
April Google Interview 3/4

Maze

N,M array

Level 1 0,0 to N-1,M-1 => Path exsits?

Level 2 if path exists then print path

Level 3 if path exists then print min cost path

Level 4 O(nm log mn) using Priority Queue.

- 2of 4 votes
April Google Interview 2/4

Count Number Given Array

Level1 Unsorted Array [1, 3, 2, 1, 2 ,3 , 4, 10]

Find occurrence of 1

Level 2 Sorted Array

Find occurrence of 1

- 0of 0 votes
You are given a string S consisting of lowercase English letters denoting different types of candies. A substring of a string S is a string S' that occurs in S. For example, "bam" is a substring of "babammm". Each candy costs 1 unit. You can pick some continuous candies such that you can create a palindrome of length K by using some or all picked candies. Your task is to find the minimum cost to create a palindrome of length K.

Input Format:

First line contains string S.

Next line contains an integer T denoting the number of test cases.

Next T lines contain a single integer K.

Output Format:

For each test case, print minimum cost as mentioned above. If you cannot create a palindrome of length K then, simply print -1.

Constraints:

Constraints:

1≤|S|≤10^5

1≤T≤10

1≤K≤10^5

Sample Input

babammm

2

2

5

Sample Output

2

5

Explanation

Test Case 1: You can pick candies denoted by "mm" and create a palindrome of size 2. So the cost will be 2 units.

Test Case 2: You can pick candies denoted by "babam" and rearrange them, "bamab", to create a palindrome of size 5. So the cost will be 5 units.

- 0of 0 votes
/**

* Definition for a binary tree node.

* public class TreeNode {

* int val;

* TreeNode left;

* TreeNode right;

* TreeNode(int x) { val = x; }

* }

*/`Find the largest duplicate subtree in a binary tree For example, 1 / \ 2 3 / / \ 4 2 4 / 4 The following are two duplicate subtrees: 2 / 4 and 4`

but the former is the largest, thus return the root of the first subtree

- 0of 0 votes
Write a function that receives string with decimal number (i.e. all characters are decimal digits) and prints the sum of all possible substring-numbers, example:

sum(“123”) = 123 + 12 + 23 + 1 + 2 + 3 = 167

- 0of 0 votes
Given N number of Strings, generate all combination of these String's characters, these Strings must be N long, and must contain only one number of char from each string.

example: "abc", "def", "ghi" --> adg, adh, adi, aeg ... cfg

- 0of 0 votes
Given a target string, an input request replaces the word after the given index a->b such as:

Target string: "Hello world!"

Input:{s:0, a:Hello b: Goodbye}

Output:"Goodbye world!".

The requirement is that input be given to several words that need to be changed at one time: {{s:0,a:Hello,b:Goodbye},{s:11,a:!,b:?},{s:6 a: World,b:friend}}

And each modified index is based on the original unmodified target string so the end result is

"Goodbye friend?"

- 0of 0 votes
given a n-ary tree, find the total distance from this node to any other nodes

class TreeNode {

int val;

List<TreeNode> children;

TreeNode(int val) {

this.val = val;

children = new ArrayList<>();

}

}

public int findDistance(TreeNode root, TreeNode node) {

}

- 1of 1 vote
How many squares are inside a m*n rectangle where some grids in the rectangle were grey and the gray grid could not appear in the small squares.

- 1of 1 vote
Given an int array, check if all the numbers can be divided into 5 consecutive numbers.

Eg: [1,2,2,3,3,4,4,5,5,6] Yes: (1,2,3,4,5) (2,3,4,5,6)

Followup: ask if you know that all the numbers are between 1 and 13,

what's a good optimization.

- 1of 1 vote
You have two matrixs, how to move the first matrix

(move up, down, left, and right) so that the two matrix in the two matrixs match most.`eg: matrix 1: matrix 2: 0 0 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0`

Then, after taking matrix1 (1 left shift + 1 down),

the number of 1 in the match with matrix2 is 3

- 0of 0 votes
how to check if two graphs are structurally identical

class UndirectedGraphNode {

List<UndirectedGraphNode> neighbors;

UndirectedGraphNode() {

neighbors = new ArrayList<>();

}

}

- 0of 0 votes
Table: Customers

id | name

1|alice

2|bob

3|carol

Table: Orders

id | customer_id | content

1|1|House

2|2|car

3|2|dog

4|10|cow

please write a query which returns all of the invalid orders (where invalid means their customer_id does not have an associated customer)

4|10|cow

- 0of 0 votes
Suppose you have a list of tasks which need to be executed. Some of these tasks have dependencies which must be executed before they are. Please provide a method which, when given a list of tasks, will provide a valid ordering in return.

Example:

Input: [ A, B, C, D ]

A <- B, C

B <- C, D

D <- C

Return: [ C, D, B, A ]