## Recent Interview Questions

- 0of 0 votes
Gives you an int m, and a set of char (0,1,2,3,4,5,6,7,8,9)

Lets you implement a function that generates a id based on the characters in the set. Each time you return a string, it must be unique. satisfying the same character can not appear consecutively more than m times, such as m = 3, "1000" is valid,

"0000" is not valid.

The smaller the string, the better.

- 1of 1 vote
Let’s say you have two input arrays with sorted elements. Find the union.

a[] = {2, 10, 14, 19, 51, 71}

b[] = {2, 9, 19, 40, 51}

Union = {2, 9, 10, 14, 19, 40, 51}

- 0of 0 votes
why we have a such long number value for object's hashcode in java.can we not have any small numbers or why java is giving that much large number for any object hash code ?

- 0of 0 votes
A group of friends are tracking the miles per gallon for each of their cars. Each time one of them fills up their gas tank, they record the following in a file: His or her name The type of car they drove How many miles driven since they last filled up How many gallons purchased at this fill up Date of the fill Their data is formatted as a comma separate value (csv) file with the following format for each row:(#person,carName,milesDriven,gallonsFilled,fillupDate) Miles are recorded as floating-point numbers and gallons as integers. Please create a program that allows members of this group to determine the miles per gallon (MPG) of each of their cars during a specific time range. Note: person may have more than one so a time range query might need to output data for one or more cars. A skeleton class will be provided; your job will be to complete the program. The principal function for querying MPG is of the form (the exact name, data types, etc., can be learned by inspecting the "solution" class in the skeleton code): GetRangeMPG(PersonName, StartDate, EndDate) Returns list of objects containing (CarName, MPG) MPG is calculated as (total miles traveled during time period)/ (total gallons filled during time period. The dates you receive in the query should be treated inclusively.

- 0of 0 votes
To push dominoes, find out how many dominoes are standing in the end

For example, the input is ".R...RL..R..L..", which means pushing the 2nd, 6th, and 12th dominoes to the right and pushing the 8th and 15th dominoes to the left. This example returns 4th. 1,7,16,17 blocks are standing

- 1of 1 vote
The question is that there are a lot of vm, what is the total vm consumption max. For example, (2,4,8), (3,5,3) this input,

This means that 2 to 4 seconds have a memory usage of 8 and 3 to 5 seconds of 3, so the answer is 11 at 3 seconds.

Return 11 to it. Note that (1,2,3) and (2,3,4) such that the middle 3+4=7 is good.

Follow up is usage is not constant, such as (1,2,1,2) the first second usage is 1,

The second second is 2, the linear increase, the highest is how much.

- 0of 0 votes
List<Integer> list=Arrays.asList(1,2,3,4,5,6);

Iterator it=list.iterator();

while(it.hasNext()){

System.out.println(it.next());

}

The above code will iterate sequentially through 1 to 6. Can we iterate the same list alternatively so that it will print 1,3,5 without changing the while loop.

- 0of 0 votes
Search for a sorted integer in an integer array that has been rotated multiple times.

- 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