## Recent Interview Questions

- 2of 2 votes

AnswerAirbnb: Design webbrowser back button

- aonecoding May 23, 2018 in United States

Your web browser supports will support three actions: back, forward and open. The init webpage is “about:blank”.

Given a sequence of commands. Return the result page.| Report Duplicate | Flag | PURGE

Airbnb Software Engineer Algorithm - 0of 0 votes

AnswersYou have been given a generator string ab from which any number of strings can be generated recursively by inserting ‘ab’ at any location. You have been given an input string to check if that given string is valid or not.(i.e. generated by given with given string.)

- akisonlyforu May 22, 2018 in India

eg.

Input: aabbab

Output: valid

Input: abbaab

Output: Invalid

I could not come up with a algorithm less than O(N*N)| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 0of 0 votes

Answersfind the sum of bit wise OR of minimum and Maximum element of all the subsets whose length is greater than 2 of the given of set.

- MukeshGupta0315 May 20, 2018 in India

for ex:-

{1,2,3} is set

then possible subsets of length is{ 1,2},{1,3},{2,3}{1,2,3} answer 1|2 +1|3 +2|3 +1|3=12| Report Duplicate | Flag | PURGE

Samsung Software Engineer Java - 0of 0 votes

AnswersGiven a singly linked list, write code to find the most frequent element value in the list and its occurrence.

- jp May 18, 2018 in United States

In case of duplicate number of occurrences, return the element value closest to the head.

A solution of time complexity O(N) average is preferred.

Sample Input: 1 2 3 4 2 3 2

Sample Output: Element 2 occurs 3 time(s)

Sample Input: 4 3 5 3 4 5

Sample Output: Element 4 occurs 2 time(s)| Report Duplicate | Flag | PURGE

C++ - 0of 0 votes

AnswersThe wildcard regex can include the characters * and + .

- alex May 17, 2018 in United States

‘+’ – matches any single character or empty character!

‘*’ – Matches any sequence of characters (including the empty sequence) For example,

Text = "baaabab":

regex = "ba*a++", output : true

regex = "ba*a+", output : true

regex = "a*ab", output : false

//empty string

Text=""

Regex= "+" , output : true| Report Duplicate | Flag | PURGE

Google Software Engineer Dynamic Programming - 0of 0 votes

AnswerGiven a multiple tree, and multiple nodes that need to be deleted,

- ajay.raj May 17, 2018 in United States

It is required to return a list of nodes so that the children of these nodes can be found after the nodes have been deleted.| Report Duplicate | Flag | PURGE

Amazon SDE1 - 0of 0 votes

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

- ajay.raj May 17, 2018 in United States

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.| Report Duplicate | Flag | PURGE

Amazon SDE1 - 1of 1 vote

AnswersLet’s say you have two input arrays with sorted elements. Find the union.

- prasad.hybris May 16, 2018 in United States

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

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

Union = {2, 9, 10, 14, 19, 40, 51}| Report Duplicate | Flag | PURGE

Amazon SDE1 Java - 0of 0 votes

Answerwhy 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 ?

- Vikas271572 May 15, 2018 in United States| Report Duplicate | Flag | PURGE

Java - 0of 0 votes

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

- pragramticProgrammer May 15, 2018 in United States| Report Duplicate | Flag | PURGE

Amazon SDE1 .Net/C# - 0of 0 votes

AnswerTo push dominoes, find out how many dominoes are standing in the end

- ajay.raj May 15, 2018 in United States

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| Report Duplicate | Flag | PURGE

Amazon SDE1 - 1of 1 vote

AnswersThe 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,

- ajay.raj May 15, 2018 in United States

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.| Report Duplicate | Flag | PURGE

Amazon SDE1 - 0of 0 votes

AnswersList<Integer> list=Arrays.asList(1,2,3,4,5,6);

- Randhir May 14, 2018 in India

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.| Report Duplicate | Flag | PURGE

Wissen Technology Java Developer Java - 0of 0 votes

AnswerSearch for a sorted integer in an integer array that has been rotated multiple times.

- teli.vaibhav May 14, 2018 in United States| Report Duplicate | Flag | PURGE

Samsung Senior Software Development Engineer Algorithm - 1of 1 vote

AnswersPrint 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

- teli.vaibhav May 14, 2018 in United States| Report Duplicate | Flag | PURGE

Samsung Senior Software Development Engineer Algorithm - 0of 0 votes

AnswersGiven an alphabet where we do not know the order of the letters also do not know the number of letters.

- teli.vaibhav May 14, 2018 in United States

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| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersI was asked this question in a recent interview for a startup.

- bulletblp4 May 13, 2018 in United States

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..| Report Duplicate | Flag | PURGE

Software Engineer - 2of 2 votes

AnswersAWS phone interview

- aonecoding May 13, 2018 in United States

Find the left view of binary tree

1

/ \

2 3

/\ \

4 5 6

/ /

7 8

/

9

return [1, 2, 4, 7, 9]| Report Duplicate | Flag | PURGE

Amazon Software Engineer Algorithm - 1of 1 vote

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

- sarunreddy82 May 13, 2018 in United States

Examples:

next_permutation (12) = 21

next_permutation (315) = 351

next_permutation (583) = 835

next_permutation (12389) = 12398

next_permutation (34722641) = 34724126| Report Duplicate | Flag | PURGE

Facebook Java - 0of 0 votes

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

- pragramticProgrammer May 13, 2018 in United States

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

Amazon SDE1 .Net/C# - 0of 0 votes

AnswersGiven a list of tasks each with memory requirements and time, only one machine has K memory.

- ajay.raj May 12, 2018 in United States

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. . .| Report Duplicate | Flag | PURGE

Amazon SDE1 - 0of 0 votes

AnswersFirst common Ancestor of Binary tree . Java Solution needed.

- sarunreddy82 May 11, 2018 in United States

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.

}| Report Duplicate | Flag | PURGE

xyz Trees and Graphs - -5of 5 votes

AnswersIf b == “1”:

- TubbyOPPO May 09, 2018 in England

quit()| Report Duplicate | Flag | PURGE

Facebook Software Engineer - 0of 0 votes

Answers1) You sell roses. Each rose cost 30 cents to buy and you can sell them for $10 a dozen.

- venkateshumamaheswaran May 08, 2018 in United States

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?| Report Duplicate | Flag | PURGE

Amazon Probability - 1of 1 vote

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

- mandy May 08, 2018 in United States

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")| Report Duplicate | Flag | PURGE

Amazon Software Engineer - 1of 1 vote

AnswersGiven a binary tree, where each node represents an integer, find the max value of path sum.

- LeetCoder May 07, 2018 in United States| Report Duplicate | Flag | PURGE

Facebook Android Engineer Trees and Graphs - 2of 2 votes

AnswersApril Google Interview 1/4

- aonecoding May 06, 2018 in Korea

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

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

is A equal to B| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm - 2of 2 votes

AnswersApril Google Interview 3/4

- aonecoding May 06, 2018 in Korea

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.| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm - 0of 0 votes

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

- rahul123625 May 06, 2018 in India

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.| Report Duplicate | Flag | PURGE

makemytrip Java Developer - 0of 0 votes

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

- rahul123625 May 06, 2018

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.| Report Duplicate | Flag | PURGE

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window