Recent Interview Questions
- 2of 2 votes
AnswersGiven n (of size m) Linked lists
- steelrahul June 16, 2015 in India for Hyderabad
Print all set(head of linked list) of link list that intersect with each other.
e.g.
1-->2-->3-->4-->5
6-->7-->8-->4-->5
8->9->10->11->12
13->14->15->12
16->17->18
1 6
8 13
16| Report Duplicate | Flag | PURGE
Amazon SDE1 - 2of 2 votes
AnswersYou have N points on a 2D surface. List K points at a shortest distance to the point (0, 0).
- tested.candidate March 22, 2015 in UK| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersPoint errors (if any) in the following pointer code and explain what it does...
- Jeanclaude March 17, 2015 in United States
char* cp(char *a)
{
char *f;
f=(char*)malloc(strlen(a)*sizeof(char));
while(*a != 0)
{
*f=*a;
f++;
a++;
}
cout<< f;
return f;
}| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test C++ - 2of 2 votes
AnswersK largest elements from a big file or array.
- karthikkamal666 July 27, 2014 in India| Report Duplicate | Flag | PURGE
Algorithm - 2of 2 votes
AnswersYou are trying to control an on-screen keyboard (e.g. on a television) that looks like this:
- msamarch1980 March 20, 2014 in United States
a b c d e
f g h i j
...
You can issue the following commands to move the cursor and select letters:
‘u’ - up
‘d’ - down
‘l’ - left
‘r’ - right
‘!’ - select letter
You are given an input string and the length of the rows in the on-screen keyboard. You must produce the sequence of commands needed to type out the input string on the specified keyboard, e.g.:
“aci”, 5 -> “!rr!dr!”| Report Duplicate | Flag | PURGE
Software Engineer / Developer Coding - 2of 2 votes
AnswersGiven a matrix consisting of 0's and 1's, find the largest connected component consisting of 1's.
- Interviewee February 27, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 2of 2 votes
AnswersFind the max height of a binary tree.
- techpanja October 22, 2013 in United States for yammer| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 2of 2 votes
Answersint board[8][8] each value in the matrix represents a character. 1-9 number represents all whites and 11-19 represents all blacks.
- ANONU March 27, 2013 in United States
Given a pawn at (x,y) print all possible moves. Assume whites are index 0 and blacks are at index 7.| Report Duplicate | Flag | PURGE
Amazon SDE1 - 2of 2 votes
AnswersArrange 1 to N in random order with no duplication.
- codomania March 07, 2013 in United States for Windows Phone| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 2of 2 votes
AnswersGiven a list of 2d points, if any two points have distance(straight line) <= k , group them together. For example. [P1,P2,P3], P1 to P2 <=k, P2 to p3<=k, p1 to p3>k. they are still in the same group. (distance relationship is chainable ) ask how many groups can you find ? I can think of N^2 time complexity with union and find. but how to do better than that? maybe NlogN or O(N)?
- laoen November 30, 2019 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersImplement an iterator<WordAndCount> which takes iterator<String> and its next() method returns the count for same word in a row. I was also asked to implement hasNext method.
- Desi May 03, 2019 in United States
WordAndCount class had two properties:
1. Word
2. Count
I was asked to implement hasNext() and next() method which basically returns a WordAndCount object.
To make it clear, following is the example:
lets say Iterator<String> has following values:
{foo,foo,foo,bar,foo,bar,bar}
iterator<WordAndCount> next() method should return this:
{{foo,3},{bar,1},{foo,1},{bar,2}}
It seemed like an easy problem and because we ran out of time during coding i think interviewer didn't ask me the follow up question. Interviewer was nice and he told me he doesn't expect me to code in time limit but he only wants to see how i approach the problem.| Report Duplicate | Flag | PURGE
Google Software Engineer - 2of 2 votes
AnswersBrace Expansion
- neer.1304 April 21, 2019 in United States
Given a string, perfrom the brace expansion
For example,
Input: s = "a{d,c,b}e"
output: {ade , ace , abe}| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersFind the indices of all anagrams of a given word in a another word.
- aonecoding October 09, 2017 in United States
For example: Find the indices of all the anagrams of AB in ABCDBACDAB (Answer: 0, 4, 8)| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 2of 2 votes
AnswersSingleton Design pattern. How you make it double ton(in even call of getInstance() first object should be return and odd call of getInstance() second instance should be return). Make it triple ton.
- neer.1304 September 04, 2017 in United States| Report Duplicate | Flag | PURGE
Goldman Sachs SDE-2 Software Design - 2of 2 votes
AnswersDesign OO food delivery app catering to use cases -
- neer.1304 December 06, 2016 in United States
1) User can search different restaurant
2) User can select a restaurant
3) User sees a menu
4) Restaurant can change the menu any time
5) User adds an item from menu
6) User orders the food
7) User can track the order in real time
8) User can cancel the order
9) User pays for the order| Report Duplicate | Flag | PURGE
Amazon SDE-2 Object Oriented Design - 2of 2 votes
AnswersGiven N meetings with their start time s1, s2 ….sn and end time e1, e2 ….enand K rooms. How to schedule maximum of N meetings in k rooms.
- rahulkumar5july July 08, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon - 2of 2 votes
AnswersA quadra tree is a tree where each node has atmost 4 child nodes(similar to a binary tree which has atmost 2 child nodes).
- gdg June 28, 2014 in India
A monitor screen (black and white) is represented by a qudra tree in the following way:
case 1: If the entire screen is white then the value in the root node is white.
similarly if the entire screen is black then the root stores black.
case 2: If the screen is neither completely black nor white then the screen is divided into 4 quadrants and the node has 4 child nodes each representing one of the quadrants.( the screen is recursively divided into subscreens).
Now given two screens represented by two quadra trees, return a quadra tree which represents the overlapping of the two screens.( assume when white and white overlaps results in white,black and white overlap results in black , black and black overlap results in black).
algo and code both have to be given.| Report Duplicate | Flag | PURGE
Microsoft - 2of 2 votes
AnswersFind the pair of numbers that sums to an integer k from an linked list.
- dke.ade January 14, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer Intern Algorithm - 2of 2 votes
AnswersCan you predict the output of the following code?
- Prithvi October 06, 2013 in Nepal for Java Developerfor (int i = 0; i < 101; i++) { if (i % 2 == 0) { System.err.print(i); } else System.out.print(i); }
| Report Duplicate | Flag | PURGE
Software Engineer / Developer Java - 2of 2 votes
AnswersGiven a n (large number) lists of customers who visited n webpages on n (large number) days, design a data structure to get customers who have visited the website on exactly “k” days and should have visited at least “m” distinct pages altogether.
- blackfever September 03, 2013 in India
Was then asked to improvise the solution as much as possible| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 2of 2 votes
AnswersYou are trying to to daemonize an unknown, black-box binary executable. The binary executable returns no output to STDOUT or STDERR. Assume that the mystery binary return code is non-zero. What troubleshooting steps might you take to learn more about what the binary is supposed to do, and why it is failing?
- longbelly March 21, 2013 in United States| Report Duplicate | Flag | PURGE
Google Site Reliability Engineer Unix - 2of 2 votes
AnswersWrite down the various test cases for railway portal system. write the situation when it can crash.
- Aalok August 27, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Testing - 2of 2 votes
AnswersGiven two numbers m and n, write a method to return the first number r that is
- GillY January 21, 2012 in India
divisible by both (e.g., the least common multiple)| Report Duplicate | Flag | PURGE
Google - 2of 2 votes
AnswersGiven a collection of two dimensional points and a number k, return the k closest points to (0,0) by Euclidean distance.
- genaker April 05, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Software Developer - 2of 2 votes
AnswersMinimum number of swaps of chars in only one string to make two strings the same
- ajay.raj February 02, 2018 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer - 2of 2 votes
AnswersSay you have an array for which the ith element is the price of a given stock on day i.
- ajay.raj March 10, 2017 in United States
Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
, but each time you sell you need to pay transaction fee, please calculate the maximum profit you can take.
public int maxProfit(int[] prices, int fee) {
}| Report Duplicate | Flag | PURGE
Google - 2of 2 votes
AnswersGiven a function getRandom that returns a random double in [0,1). Write a function getRandomPermutation(int n) that takes a positive integer n as argument and returns a random permutation of first n natural numbers.
- AlgoBaba November 15, 2016 in India| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersYou want to design a Cab system which will show you nearest 5 taxis.
- Shanky.Q3 July 04, 2016 in United States
Each taxi will continuously emit (x,y) coordinates.
You need to print the nearest 5 taxis from (p,q).| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 2of 2 votes
AnswersWhat is the fastest way to compute cube root?
- Ray November 14, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm