Software Engineer / Developer Interview Questions
- 2of 2 votes
AnswersDuring appraisal due to bell curve funda a manager is restricted to give promotion to only one of his team members. Three of his team members are equally competant. He wanted to select one by giving a puzzle. He called his three talented team members and blidfolded them. He placed a hat on each of their heads. Manager took off their blindfolds and gave following clues and conditions
- Durga March 28, 2015 in India
1) Each hat is either white or blue
2) There is atleast one blue hat
3) Contest is fair for all the three team members
4) Each team member can see the hat of other team members but not his.
5) The team members should not communicate to each other.
The manager declared that who ever comes up first with right answer shall be given promotion.
The most talented of his team members came up with right answer and explanation.What is the answer and the logic behind that?| Report Duplicate | Flag | PURGE
Thomson Reuters Software Engineer / Developer Puzzle - 1of 1 vote
AnswersAssume we only take the least significant digit of each value in fibonacci sequence, and form the sequence of digits into pairs. In those pairs, the first value of one pair is the same as second value of its predecessor.
- evi March 22, 2015 in United States
As we know the fibonacci sequence is 1, 1, 2, 3, 5, 8, 13, 21...
so the pair sequence is:
[1, 1], [1, 2], [2, 3], [3, 5], [5, 8], [8, 3], [3, 1] ...
Write a function to output the first n pairs of this sequence.
void Outputpairs(int n)| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 4of 4 votes
AnswersGiven an array Of integers build a new array of integers such that every 2nd element of the array is greater than its left and right element.
- Gaurav Shah March 17, 2015 in United States for Chrome Team
eg:
[1,4,5,2,3]
o/p:
[1,4,2,5,3]
Soln proposed:
Step 1:Sort The array -> O(nlogn)
Step 2:Use 2 indices: one starting at leftmost index and other at rightmost index.
and populate the new array alterntely using the left pointer(index) first and then the right pointer and then increment the pointer used. till both the pointers meet/cross each other. -> O(n).| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 2of 2 votes
Answersgiven an expression like 3*4 + 8-9 (only +, - , * operators) as a string evaluate it strictly from left to right
- boomla March 17, 2015 in United States| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Algorithm - 0of 0 votes
Answerssnake sequence. same as in other interviews
- boomla March 17, 2015 in United States| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Algorithm - -2of 2 votes
Answersgiven a horizontal array of strings convert it to vertical. like english characters are read left to right. convert them to a chinese format which is read vertically.
- boomla March 17, 2015 in United States
eg.
epic is a healthcare company.
interviewing for software developer.
print this vertically sentence by sentence.| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Algorithm - 4of 4 votes
AnswersGiven an m x n matrix where each row element is sorted, but the columns do not appear in sorted order, write a function to print each matrix element in sorted order.
- seanchen11235 March 06, 2015 in United States
Example matrix:
matrix = [
[20, 40, 80],
[5, 60, 90],
[45, 50, 55]
]
Your function should print 5, 20, 40, 45, 50, 55, 60, 80, 90.
Add on: Assume that we are space-constrained such that we can only hold one row in memory at a time. Optimize your function to work under such constraints as efficiently as possible.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou are given an N*N matrix. The matrix contains characters. Write a program to find a word in the matrix.The word can be found in either the rows or columns or the diagonals. The program should return true if the word is found and false if the word is not found.
- alregith March 03, 2015 in United States| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Arrays - 0of 0 votes
AnswersThis was asked in an Online written test that was timed (60 mins). And this question was one among the three.
- Jeanclaude March 03, 2015 in United States
"Write a method to merge three sorted integer arrays into just one array"
Nothing more or less was given. Since it was a written test I assumed that the 1st array had space towards to end which can fit the other two arrays. I can code this but given the timer limitations (of 20 mins per question) I thought it was a bit too much for me to handle unless there is a more obvious way to do this. I did it using two arrays and using the resultant array, I merged it with the 3rd array. That was the best i could think of at that time.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Sorting - 1of 1 vote
AnswersAmazon wants to implement a new backup system, in which files are stored into data tapes. This new system must follow the following 2 rules:
- anca.grigoras88 February 16, 2015 in United States
1. Never place more than two files on the same tape.
2. Files cannot be split across multiple tapes.
It's guaranteed that all tapes have the same size and that they will always be able to store the largest file.
Every time this process is executed, we already know the size of each file, and the capacity of the tapes. Having that in mind, we want to design a system that is able to count how many tapes will be required to store the backup in the most efficient way.
The parameter of your function will be a structure that will contain the file sizes and the capacity of the tapes. You must return the minimum amount of tapes required to store the files.
Example:
Input: Tape Size = 100; Files: 70, 10, 20
Output: 2| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersReverse left node of BT.
- frustatedALGO February 12, 2015 in United States
1 (ROOT)
/ \
2 3
/ \
4 5
/ \
6 7
to
1
/
2 - 3
/
4 - 5
/
6 - 7
(6 is root)| Report Duplicate | Flag | PURGE
xyz Software Engineer / Developer C++ - 3of 3 votes
AnswersFind a given element in sorted array.
- tazo February 10, 2015 in United States
arr= [1, 2, 3, 4, 5, 6]
follow up: If the sorted array is shifted left by unknown number, modify existing binary search to find a element in modified array
arr = [4, 5, 6, 1, 2, 3]| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Arrays - -1of 1 vote
AnswersYou're the guard of a prison, you want to keep an eye on the most dangerous prisoner. Each prisoner has a danger rank of his own and a group of friends (who also have danger ranks). You'll need to go through the prison and find out the prisoner who has the highest danger rank (his own + all his friends)
- Sai February 08, 2015 in United States| Report Duplicate | Flag | PURGE
Software Engineer / Developer Algorithm Problem Solving - 0of 0 votes
AnswersEnumerate all possible anagrams of a random string where capital letters, numbers, and symbols are not allowed to move within the string.
- chutzpah February 06, 2015 in United States| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer - 0of 0 votes
AnswersYou're the guard of a prison, you want to keep an eye on the most dangerous prisoner. Each prisoner has a danger rank of his own and a group of friends (prisoners, who also have danger ranks). The guard has a list of prisoners with their corresponding danger ranks and he also has a list of the friends of each of the prisoners in the prison.
- Sai February 03, 2015 in United States
The danger rank is computed as follows: Prisoner 1 has a danger value of 5, his friends are Prisoner 2 and Prisoner 5, who have danger values of 3 and 4 respectively. So the danger value of Prisoner 1 is 5+3+4 = 12.
There could be any number of prisoners. Whichever prisoner has the highest value is the most dangerous(computed using the above method).
Friendship can be assumed to be symmetric.
Come up with an efficient algorithm to find the most dangerous prisoner?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou given and instruction called DBNZ ( Decrement and Branch if Not Zero)
- srcnaks February 02, 2015 in -
which can be used as "DBNZ X L10".
This instruction decrement X by one and checks X, if X is not zero than branches line 10,
if it is zero than continue to next instructions.
By using DBNZ instruction implement CLEAR instruction.
CLEAR can be used as "CLEAR X" which means set X to zero.
By using DBNZ and CLEAR instructions implement NEGATE instruction
NEGATE can be used as "NEGATE X Y" which means set Y to negative of X ( Y = -X)| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Assembly - 1of 3 votes
Answersdesign and implement a calculater that can calculate expressions like:
- srcnaks February 02, 2015 in -
+ 2 4
* 8 ( + 7 12)
( + 7 ( * 8 12 ) ( * 2 (+ 9 4) 7 ) 3 )
(PS:all items are space delimetered.)
Example answers
+ 2 4 => 2 + 4 = 6
* 8 ( + 7 12) => 8 * ( 7 + 12 ) = 152
( + 7 ( * 8 12 ) ( * 2 (+ 9 4) 7 ) 3 ) => 7+8*12+2*(9+4)*7+3 = 148| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Data Structures Problem Solving Stacks String Manipulation Trees and Graphs - 2of 2 votes
Answersthere are numbers in between 0-9999999999 (10-digits) which are assigened someone (does not matter which number assigned who)
- srcnaks February 02, 2015 in -
Write two methods called "getNumber" and "requestNumber" as follows
Number getNumber();
boolean requestNumber(Number number);
getNumber method should find out a number that did not assigened than marks it as assiged and return that number.
requestNumber method checks the number is assigened or not. If it is assigened returns false, else marks it as assiged and return true.
design a data sturucture to keep those numbers and implement those methods| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Data Structures Hash Table - -1of 1 vote
AnswersSuppose you receive 10 million mails in 10 seconds. How will you process them and find what might be the reasons to receive these many mails. Discuss different approaches to find the reasons.
- Rahul Sharma January 29, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 8of 8 votes
Answers1. qaz is a value for a number where this number is less than the other next values which have indexes larger than the index of this number.
- Pointer January 27, 2015 in United States for Autocomplete
for example: 33 , 25 , 26 , 58 , 41 , 59 -> qaz of (33) = 3 where 33 less than 3 numbers (58 , 41 , 59), qaz of (25) = 4 and not 5 because the index of 33 is less than the index of 25, qaz of (26) = 3 , qaz of (58) = 1 , qaz of (41) = 1 , qaz of (59) = 0.
the question is to find the max qaz.
it can be solved simply using 2 loops which takes time of O(n^2).
that's ok but how can we solve this problem in O(nlogn).
I have an approach and know the algorithm I got during the interview but it take a 40 of me to find it and write the code, but it was hard to think about it during the interview in that way.
I want to know if somebody can think and write the code in less than 20 minutes !!!| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 1of 1 vote
AnswersWrite a function that receives a stream of pairs: id (some unique integer) + weight (positive real number).
- Anonymous January 27, 2015 in Israel
The stream ends with the special pair {0,0}.
The function should return one the unique ids at random, with probability proportional to its weight (compared to the total weights sum when stream has ended).
Stream size and weights sum are unknown in advance, and you are allowed O(1) memory consumption.
Example: If this was the stream: {1,2},{2,2},{3,4},{4,10}, then id 2 would be returned with probability 1/9.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 1of 1 vote
AnswersWrite a class that receives in the constructor a vector of strings representing a browser history (URLs), and a method for "auto-complete":
- Anonymous January 27, 2015 in Israel
The method that receives a string representing a partial URL typed by the user and returns a vector of all possible completions of this partial URL (prefix).| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersYou are given a binary search tree and a positive integer K. Return the K-th element of the tree.
- Anonymous January 27, 2015 in Israel
No pre-processing or modifying of the tree is allowed.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures - 3of 3 votes
AnswersYou are given an array of distinct numbers. You need to return an index to a "local minimum" element, which is defined as an element that is smaller than both its adjacent elements. In the case of the array edges, the condition is reduced to one adjacent element.
- Anonymous January 27, 2015 in Israel
Reach a solution with better time complexity than the trivial solution of O(n).
If there are multiple "local minimums", returning any one of them is fine.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 0 votes
AnswersYou are given a positive integer number N. Return the minimum number K, such that N can be represented as K integer squares.
- Anonymous January 27, 2015 in Israel
Examples:
9 --> 1 (9 = 3^2)
8 --> 2 (8 = 4^2 + 4^2)
15 --> 4 (15 = 3^2 + 2^2 + 1^2 + 1^2)
First reach a solution without any assumptions, then you can improve it using this mathematical lemma: For any positive integer N, there is at least one representation of N as 4 or less squares.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 1of 1 vote
AnswersYou are given a double linked list and an array of pointers to elements in this list (no assumptions can be made on the array - number of pointers, order and duplicates allowed).
- Anonymous January 27, 2015 in Israel
Return the number of sequences of elements (groups of consecutive elements), pointed by the array.
For example, if this is the array (number relates to index in the list, not the actual pointer value): 9,1,3,7,8,5,2.
Then output is 3, representing these sequences: [1,2,3], [5], [7,8,9]| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures - 0of 0 votes
AnswersGiven a 2D array of size nXn with values from 1 to n^2 permuted in the 2D array i.e no duplicates.
- Anton January 27, 2015 in United States
Find the longest snake in the array such that snake can go upward, downward, right, left and each and every adjacent value in the snake should differ by 1.
Ex:
2 5 6
3 4 9
1 7 8
Answer is 5. [2,3,4,5,6].| Report Duplicate | Flag | PURGE
Software Engineer / Developer Algorithm - 2of 2 votes
Answers2D matrix with 0s and 1s. Try to find out how many countries in this matrix?
- JY January 24, 2015 in -
For example:
[[1,1,1,0]
[1,1,0,0]
[0,0,0,1]]
return 3, because one for 1s, one for 0s, and one for the last one.
another example:
[[1,1,1,1]
[0,0,0,0]
[1,0,0,1]]
return 4| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 1of 3 votes
AnswersYou are given a 2D Array that contains only 0s and 1s in sorted order. i.e. First Os and then 1s.
- tihor January 24, 2015 in India
Array:
0 0 0 1
1 1 1 1
0 0 1 1
0 1 1 1
You have to figure out the row that contains maximum number of 1s.
e.g. in above case we have row 2 as the answer.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm