Recent Interview Questions
- 3of 3 votes
AnswersYou have N toffee packets, each containing different number of toffees. The number of toffees contained in the ith packet is denoted by ci. You need to put these toffee packets in 5 boxes such that each box contains at least one toffee packet, and the maximum number of toffees in a box is minimum.
- parni November 01, 2018 in United States
You can only choose consecutive toffee packets to put in a box.| Report Duplicate | Flag | PURGE
Google - 3of 3 votes
AnswersGiven a string with alpha-numeric characters and parentheses, return a string with balanced parentheses by removing the fewest characters possible. You cannot add anything to the string.
- genaker April 05, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Software Developer - 3of 3 votes
AnswersGiven a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temperature.
- md.lisul.islam November 22, 2017 in United States
[73, 74, 75, 71, 70, 76, 72] -> [1, 1, 3, 2, 1, nothing, nothing]| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 3of 3 votes
AnswersWrite a function to label connected components (using 4-connected neighbors) in a binary image.
- davydany August 01, 2014 in United States
You may use any language or data structures, but you may not use any existing APIs/libraries to find the components.
Example:
Input image
0 0 0 0 0 1 1 0 0 0
1 1 0 0 1 1 0 0 0 0
1 1 1 0 0 1 1 0 0 0
0 0 0 1 1 0 0 0 0 0
Output Image
0 0 0 0 0 1 1 0 0 0
2 2 0 0 1 1 0 0 0 0
2 2 2 0 0 1 1 0 0 0
0 0 0 3 3 0 0 0 0 0| Report Duplicate | Flag | PURGE
Amazon Research Scientist Algorithm - 3of 3 votes
AnswersGiven an array of 1 billion numbers with just a few 100 missing, find all the missing numbers. you have only enough memory to store only 10k elements
- PS October 07, 2016 in United States| Report Duplicate | Flag | PURGE
Amazon Senior Software Development Engineer Algorithm - 3of 3 votes
AnswersStarting at the 0 (zero) index, you need to "jump" through a one-dimensional array (zero based index) of true/false values. True is a place you can land on (if desired) and false is a place you must jump over (cannot land on). The array can be very very long.
- intervyou May 25, 2014 in United States
Your "velocity" indicates how many spots (or array indexes) you advance with every jump. For example, if you have a velocity of 2 and are currently at index 4, after the jump, you will be at index 6. Before each jump you can increase your velocity by 1, decrease your velocity by 1, or keep the same velocity. You can only go forwards.
You start at index 0 (zero), with a velocity of 1. This means that for the very first jump, you can keep the same velocity and move to index 1, or increase velocity by 1 (to a velocity of 2) to move to index 2. On this first jump, you can't decrease your velocity as that would make your velocity 0 (zero) and you wouldn't move. Now that you've jumped, you can again increase, decrease, or keep your velocity the same, then jump again.
As an example, let's say you increased your velocity to 2 and jumped. You're now at index 2 with a velocity of 2. You can:
1) decrease your velocity to 1 and jump to index 3.
2) keep your velocity at 2 and jump to index 4.
3) increase your velocity to 3 and jump to index 5.
Remember, you can only and on an index if it's "true". You are successful if you can get past the last index. Implement a function to determine if the rabbit can make it across given the field (array).
Here is a field that the rabbit cannot cross:
$field = array(true, true, false, true, false, true, false, false, false, true);
Here is a field that the field can cross:
$field = array(true, true, false, true, false, true, true, false, false, true, false);| Report Duplicate | Flag | PURGE
Algorithm - 3of 3 votes
AnswersYou have three jars filled with candies. One jar is filled with banana candies, one jar is filled with lemon candies and one jar has a mix of both. All the jars are mislabelled (i.e. all the jars have wrong labels about what kind of candies they contain).
- rpisid November 14, 2013 in United States
All the candies look very similar in shape, size and color and they even smell the same. The only way to distinguish them is by tasting.
You have to eat one and only one candy to determine the correct jar labels. You can eat that one candy from any jar you want as long as you eat only one in total.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Brain Teasers - 3of 3 votes
AnswersQ: Do you know what is a stack? Explain
- Aditya April 14, 2013 in United States
A: Yes, explained LIFO push pop peek
Q: In stack, Push and Pop are constant. What will you do if you want an operation which gives the min of the stack also in constant time?
A: Question is straight out of Gayle's Book. You just maintain a new stack of minimum number till that point.| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer Stacks - 3of 3 votes
AnswersGiven pointer to the bytes array on size N that represents big integer "a" and 2-bytes integer "b" implement mod (%) operation for them: a % b
- russ.kovich December 14, 2012 in United States for Bing| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Bit Manipulation - 3of 3 votes
AnswersGiven two sorted arrays find the element which would be N-th in their merged and sorted combination.
- tested.candidate July 14, 2015 in Switzerland| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 3of 3 votes
AnswersWhen is that we we want to use "user virtual address" instead of "kernel virtual address"? List some situations when we cannot go with kernel virtual address.
- chvishu87 April 06, 2013 in United States| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Linux Kernel - 3of 3 votes
AnswersWrite a function to sum up two polynomials. Design the data structure for polynomial.
- styx.han February 25, 2013 in United States| Report Duplicate | Flag | PURGE
Arrays - 3of 3 votes
AnswersGiven a list of input tasks to run, and the cooldown interval, output the minimum number of time slots required to run them.
- nzt July 26, 2017 in United States
// Tasks: 1, 1, 2, 1, 2
// Recovery interval (cooldown): 2
// Output: 8 (order is 1 _ _ 1 2 _ 1 2 )
=========
Tasks are task numbers in that order coming in for execution. Cooling time is time interval required to cool down the machine after executing a task. So it's like if CPU executed task 1 then it needs 2 cooling time intervals before executing another task 1 but meanwhile, it can execute other tasks which are not same as 1 and so on. So before executing any task, you have to check if you have executed same task number before and if yes, then if its cooling time interval is done or not.
The output is basically the number of cycles/time slots CPU took to execute these tasks in that order (including when task executed and cooling intervals).| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 3of 3 votes
AnswersAs an input, you have points on a 2D graph. You aim to find a straight line that can fit as my points as possible. Return, the maximum number of points you can fit.
- Bobika December 05, 2016 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 3of 3 votes
AnswersPrint all paths of a binary tree from root to leaf.
- meh March 23, 2014 in United States
Later, extend the solution to work with graphs, careful attention to cycles which you should print as paths as well (without printing visited nodes twice).| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Data Structures - 3of 3 votes
AnswersDesign a Restaurant Reservation system.
- learner January 09, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Object Oriented Design System Design - 3of 3 votes
AnswersFind whether string S is periodic.
- aonecoding January 20, 2018 in United States
Periodic indicates S = nP.
e.g.
S = "ababab", then n = 3, and P = "ab"
S = "xxxxxx", then n = 1, and P = "x"
S = "aabbaaabba", then n = 2, and P = "aabba"
follow up:
Given string S, find out the P (repetitive pattern) of S.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 3of 3 votes
AnswersGiven the root of a Binary Tree along with two integer values. Assume that both integers are present in the tree.
- teli.vaibhav October 30, 2016 in United States
Find the LCA (Least Common Ancestor) of the two nodes with values of the given integers.
2 pass solution is easy. You must solve this in a single pass.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 3of 3 votes
AnswersImagine a man reading a book.
- zr.roman November 16, 2015 in Russia
He can perform only 2 possible actions of reading:
1) read a page in a minute (careful reading),
2) read two pages in a minute (look through).
Nothing else is permitted.
Calculate the number of all possible combinations of book reading ways with given number of pages.
Example: given 3 pages.
Answer is 3 combinations, as follows:
1st: Careful reading (1) - careful reading (1) - careful reading (1),
2nd: Careful reading (1) - look through (2),
3rd: Look through (2) - careful reading (1).| Report Duplicate | Flag | PURGE
SDE-2 Algorithm - 3of 3 votes
Answershow to sort a list with dictionary as variables.Sort should be based on dictionary value.
for example :a = [{'b':2},{'b':1},{'b':5}{'b':4]
now the sort should be based on value.
- rkcchaitu June 02, 2017 in India| Report Duplicate | Flag | PURGE
Software Engineer in Test Python - 3of 3 votes
Answerswhich data structure should be used to implement thread pool ? How to assign particular thread from thread pool ?
- sumit kumar May 22, 2013 in India| Report Duplicate | Flag | PURGE
Senior Software Development Engineer C++ - 3of 3 votes
AnswersHow would you design transfer of data packets from NY to Tokio?
- gbabun April 26, 2011
First I thought of traveling salesman problem where weight of connections between nodes is throughput of network. This problem is NP which lead just to interviewers reply that I should care about design of system, recovery of data and acknowledge whether data has been transferred.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Computer Architecture & Low Level - 3of 3 votes
AnswersDesign backend system for bookMyShow.com like system which supports below use cases:
- Priyanka March 29, 2017 in India
1) When user selects cities, list of cities is displayed.
2) When user selects city, movie list is displayed.
3) When user selects movie, list of theatre is displayed.
4) When user selects theatre, show timing is displayed.
5) When show timing is selected, user is asked for no of seats that he wants to book
6) When user selects no of seats, seats are displayed to choose from.
7) When user selects seats, then total price is displayed.
8) When total price is selected, then user is directed to payment gateway and payment is done and on payment success, ticket is mailed to him.
More questions on how can we scale the system, and handle concurrent users request for same seat etc.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Object Oriented Design - 3of 3 votes
AnswersGiven a sorted array. Now following operations may be applied on even position elements:
- NIC October 03, 2014 in India
swap elements on even position. An element may be swap only once.
eg. 1 2 3 4 5 6 7 8 9 10
modified array:
1 2 3 8 5 10 7 4 9 6.
Find any given element in less than o(n) complexity.| Report Duplicate | Flag | PURGE
Josh Software Engineer / Developer Algorithm - 3of 3 votes
Answerswhen we have to override equals and hashcode in java..?
- PRASHANTGAURAV November 12, 2013 in India
what will happened if you dont override .. Explain with program.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Java - 3of 3 votes
AnswersFirst the interviewer have called me on time, he introduced himself and his project which takes about 10 minutes, then he asked me why do you want to join facebook..
- neal January 05, 2011
Then he started in the technical questions, the first questions was:
he described to me a game called othelo (http://en.wikipedia.org/wiki/Reversi) which is a 2 player board game using for example X and O, if player X placed X in an empty space
_OOOX
the O's between the two X's will be converted to X
XOOOX ==> XXXXX
this will happen on the current row, column, and the two diagonals in every directions
and if the following case happened
__OOX
and the X player placed X in the first space
X_OOX
nothing occured for the two Os
given a certain state of the board, location on the board, a certain piece
to place on the given location
update the board, and make the required validations
Then I started to code the required method, then have revised it and fixed small bugs, then he told me that it seems to be working.
then we turned to the second question:
which is given a Collection<String> words, return a Collection<String> of anagrams found in the given collection for example "The rat fell in the tar" => returned [rat tar]
Then I have discussed him in an algorithm with O(n k lg k) where n is the number of words and k is the average length of the word, then I started to code it and then he said that it seems to be working.
then the interview is finished.
Notes:
* Try to practice a lot before the interview, by solving such problems and try to mimic the interview environment by coding in the collabedit.com text editor
* Don't use Ctrl + S while coding in collabedit as it may lead to some problems.
* Don't be afraid before the interview, just calm down as the interviewers are very friendly.
Good Luck :)| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 3of 3 votes
AnswersAverage Marks of Lowest ID Student:
- hkadam36 May 27, 2021 in United States
In this problem, you have to write a program that reads a file containing scores received by students in a number of
subjects, and does some processing on it.
The input is being read in from a file called input.txt, in this format:
22, Data Structures, 45
23, English, 52
22, English, 51
26, Data Structures, 72
23, Data Structures, 61
24, English, 81
Each line consists of three fields "Student ID," "Subject," and "Marks." "Student ID" and "Marks" are integers and
"Subject" is a string that does not contain commas or newlines. There can be any number of students and up to 6 subjects.
Your program should read this file, compute the average marks scored across all subjects by the student with the lowest ID, and write the average marks to a file called output.txt.
For example, if your program is run with the input given above, then at the end the file output.txt should contain just
48. That's because 48 is the average of the marks received by the student with ID 22 (which is the lowest ID).
***Need code in python****| Report Duplicate | Flag | PURGE
Python