## Recent Interview Questions

- 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.

- 3of 3 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 ]

- 0of 0 votes
There are N (N > 20) team, each team will play 'M' (say M =3) league match against every other team. Design various classes, and write the code and algorithm to find the winner.

Note: One match can be played on a single day, as there is just one stadium.

Note: No team should play matches on consecutive days.

Note: Algorithm should come up with Quarter Final, Semi Final, and Final matches.

Follow-up Question: If N is odd or even.

How your design will be modified if there are 'S' no. of stadiums.

- 1of 1 vote
convert a Sorted array to complete BST

- 0of 0 votes
Design a Twitter-like topic system so that the most popular topics can be retrieved from the system. A post can have one or more topics and these topics can be shared by multiple posts. (hint: thinking of scalability)

- 0of 0 votes
How HP Customer Support Works for Users?

- 0of 0 votes
Give a connected graph, no cycle,

Find the node where the average distance from all other nodes is the smallest

- 0of 0 votes
Input: an int array without sorting, then do a binary search on it, and find the number of digits that cannot be found by binary search.

- 0of 0 votes
<key = "a"; val = "3"; depend_list = null;/>; <key = "b"; val = "a * a";

Depend_list = {a};/>; <key = "c"; val = "a * b"; depend_list = {a,b};/>;

Lets output a map<key, value>,a -> 3, b -> 9, c -> 27

Follow-up questions: Make a statistic for all keys and corresponding map entries with the same value.

- 0of 0 votes
Given an array, find an x such that all numbers less than x are equal to themselves. Numbers greater than it are equal to x, and all numbers add up to a target

For example, [1 3 5 7 9] target=24, answer is8. Because when x=8, the array has only 9>8, so 1+3+5+7+8=24 is the closest to the target.

- 0of 0 votes
Give an N-length array with only 0 and 1 inside

Requires to find the minimum number of conversions needed to convert the array to 0 before all 1.

The conversion is to change a 0 to 1 or a 1 to 0,

And the number of 0 and 1 in the converted array can be arbitrary.

Just find the minimum conversion step

- 0of 0 votes
Why Do You Need of QuickBooks Support?