Recent Interview Questions
- 16of 18 votes
AnswersOutput top N positive integer in string comparison order. For example, let's say N=1000, then you need to output in string comparison order as below:
- John July 15, 2014 in United States
1, 10, 100, 1000, 101, 102, ... 109, 11, 110, ...| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 16of 18 votes
AnswersMachine Coding:
- ponmurugesh2012 May 20, 2014 in India
Design and code application similar to IPL website.
1. There are players who belong different teams [CSK, RCB,etc].
2. User can create their own team from the player set
3. When a match happens, there are possible outcome in each ball [one run, six, wicket, run-out, etc]
4. on each outcome, players involved will get points [eg: six = batsman 5 points, wicket = batsman minus 5 and bowler +5, etc]
5. Based on outcome, the user created team also should be able to calculate his points.
6. Solution should be working code, extensible and performance.| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Coding - 16of 16 votes
AnswersDesign a System Which contains multiple components, And all components are in same Assembly. All These Components are independent.
- csenasa August 10, 2013 in India
Design a Communication System such that:-
a. Sender is Not Aware of Reciever
b. Any New Component Addition Should Not Change the System Implementation.
( I Guess Interviewer also Not aware What he was asking ;) :P When he told sender is not aware if receiver hehehe)
2. Design a System to Handle Different Type of Objects
And Perform an Operation on the Sender Object.
a. Design to scale , it should handle huge number of Different kind of objects.| Report Duplicate | Flag | PURGE
Intuit Senior Software Development Engineer System Design - 16of 16 votes
Answers Given Two array with the preference of two developers say Ying and Ming, both need to create a team according to the preference, you need to return the String containing the Initial of the team the developers got selected it Note: Ying will always got the chance to make a first pick? {{{Example says Ying Preference table [1,2,3,4] and Ming Preference table is [1,2,3,4] than the Output should be 'YMYM' 2nd Example Ying Preference input array [1,3,2] and Ming Preference input array is [3,1,2] than the String return would be 'YYM'. - sam21088 June 22, 2020 in India for PWM| Report Duplicate | Flag | PURGE
Morgan Stanley Java Developer Algorithm - 15of 15 votes
AnswersGiven a set of 2D points, some integer k, find the k points closest to the origin, (0,0).
- peetonn March 09, 2013 in United States| Report Duplicate | Flag | PURGE
Facebook iOS Developer Algorithm - 15of 15 votes
AnswersThere is a graph which has 1 source and 1 sink(destination node)
- student1234 August 28, 2015 in United States
In between those 2 nodes there are n levels of nodes. At each level there are exactly m nodes.
Every node of level i is connected to every node of level i+1 (All edges go in forward direction)
Find total no. of paths between source and sink.
This was basic question. Then he tweaked it by adding few more edges.
Now there were some additional edges. Now sdges can go from any lower level to any higher level. That is not just from i to i+1..
can be from i to i+2 or i +3 so on...
(such bouncing edges were added only in the n levels not from or to (to src or sink)
Now find number of paths?| Report Duplicate | Flag | PURGE
Google Algorithm - 15of 15 votes
AnswersGiven an array having 16000 unique integers, each lying within the range 1<x<20000, how do u sort it. U can load only 1000 numbers at a time in memory.
- vgeek July 27, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 15of 15 votes
AnswersImplement a stack that in addition to push and pop has a function that returns the min value of the stack.
- theProgrammer April 10, 2017 in United States for Alexa
I came up with a O(logn) solution, but he wanted a O(1) for the whole algorithm.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures - 15of 15 votes
Answersif(fork())
- gladiator January 19, 2012 in India
printf("MAGIC\n");
what is output??| Report Duplicate | Flag | PURGE
Arista Networks - 15of 15 votes
AnswersA startup website has a lot of real-time traffic . I want to see the real-time view (refreshed every 1 min) of top 20 users by hit count within last 10 mins. Full distributed system, I have to resolve all the concurrency issues.
- acharyashailendra1 December 22, 2019 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 15of 15 votes
AnswersYou are given a directed cyclic graph represented by an adjacency matrix. The graph has at least one terminal node (i.e. the node with no outgoing edges).
Each edge of the graph is assigned a positive integer representing a probability of taking this edge. E.g. if you have 3 outgoing edges with numbers 3, 2, and 4, this means that the prob. of taking these edges are: 3/9, 2/9 and 4/9, respectively.
You need to find the probability of reaching each terminal node from the starting node 0.
Example:
adjacency matrix 5x5:m = {{0 1 0 0 1}, {0 0 3 2 0}, {4 0 0 1 0}, {0 0 0 0 0}, {0 0 0 0 0}}
so we have two terminal nodes here: 3 and 4
- pavel.emeliyanenko@toptal.com May 11, 2021 in United States
we can take the following paths:
0 -> 1 -> 3 = probability: 1/2*2/5 = 1/5
0 -> 1 -> 2 -> 3 = probability: 1/2*3/5*1/5 = 3/50
0 -> 1 -> 2 -> 0 -> 1 -> 3 ... and so on
or to the node 4:
0 -> 4: probability: 1/2
0 -> 1 -> 2 -> 0 -> 4: probability 1/2*3/5*4/5*1/2 = 3/25
and so on, summing up probabilities of all possible paths we get:
total probability to reach node 3: 13/38
total probability to reach node 4: 25/38| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 14of 16 votes
AnswersDesign an architecture for REST APIs where you have to upload big data like images/videos etc. Request should be async. Follow up: How will you tune the performance if you have millions of requests coming at same time? Clues: Queueing the request, Storing data in filesystems rather than traditional DB etc.
- techpanja October 02, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Senior Software Development Engineer Distributed Computing - 14of 14 votes
AnswersGiven a 2-D matrix represents the room, obstacle and guard like the following (0 is room, B->obstacle, G-> Guard):
- Obiwana March 10, 2014 in United States
0 0 0
B G G
B 0 0
calculate the steps from a room to nearest Guard and set the matrix, like this
2 1 1
B G G
B 1 1
Write the algorithm, with optimal solution.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 14of 14 votes
AnswersWrite a program to check whether it is a valid binary tree or not. Check all test cases (e.g. No left Node case).
- Neelavan October 02, 2016 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 14of 14 votes
AnswersHow volatile is implemented by compiler? is it just by disabling optimization of the code which uses the variables qualified with volatile or something more than that?
- bvgr January 30, 2013 in United States| Report Duplicate | Flag | PURGE
CSR C - 13of 19 votes
AnswersWrite a program to find whether a given number is a perfect square or not. You can only use addition and subtraction operation to find a solution with min. complexity.
- Purushotham Kumar June 12, 2013 in Ireland
i/p : 25
o/p : True
i/p : 44
o/p: False| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 13of 13 votes
AnswersA book contains with pages numbered from 1 - N. Imagine now that you concatenate all page numbers in the book such that you obtain a sequence of numbers which can be represented as a string. You can compute number of occurences 'k' of certain digit 'd' in this string.
- autoboli January 16, 2015 in United States
For example, let N=12, d=1, hence
s = '123456789101112' => k=5
since digit '1' occure five times in that string.
Problem: Write a method that, given a digit 'd' and number of its occurences 'k', returns a number of pages N. More precisely, return a lower and upper bound of this number N.
Example:
input: d=4, k=1;
output {4, 13} - the book has 4-14 pages
input d=4 k=0;
output {1, 3} - the book has 1-3 pages| Report Duplicate | Flag | PURGE
Google - 13of 13 votes
AnswersHow its possible to have only a specific Functionality as per the user Object should have , not all the functionality of the class to be loaded in object only user specific functionality?
- d.sujith November 27, 2012 in India| Report Duplicate | Flag | PURGE
Aricent Technical Architect - 12of 14 votes
Answerswe will name a number "aggregated number" if this number has the following attribute:
- holmespanda November 16, 2012 in United States
just like the Fibonacci numbers
1,1,2,3,5,8,13.....
the digits in the number can divided into several parts, and the later part is the sum of the former parts.
like 112358, because 1+1=2, 1+2=3, 2+3=5, 3+5=8
122436, because 12+24=36
1299111210, because 12+99=111, 99+111=210
112112224, because 112+112=224
so can you provide a function to check whether this number is aggregated number or not?| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 12of 12 votes
AnswersGiven a string which only contains lowercase. You need delete the repeated letters only leave one, and try to make the lexicographical order of new string is smallest.
- lxfuhuo September 09, 2015 in -
i.e:
bcabc
You need delete 1 'b' and 1 'c', so you delete the first 'b' and first 'c', the new string will be abc which is smallest.
ps: If you try to use greedy algorithm to solve this problem, you must sure that you could pass this case:
cbacdcbc. answer is acdb not adcb
I can't solve this problem well and the interviewer said that you can scan the string twice. First scan is do some preprocess, and the second is to get the answer, but I really can't come up this idea.| Report Duplicate | Flag | PURGE
Google Software Developer Algorithm - 12of 12 votes
AnswersGiven 2 arrays.Imagine you are making bst from each array.u need to tell whether 2 bsts will be identical or not without actually constructing the tree.
- bharat June 03, 2013 in India
Ex:
2 3 1
2 1 3
will construct the same tree
A1[]={2,1,3}
2
1 3
A2[]={2,3,1}
2
1 3| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 12of 12 votes
AnswersGiven a mapping of alphabets to integers as follows:
- skrish August 13, 2014 in United States
1 = A
2 = B
3 = C
...
26 = Z
Given any combination of the mapping numbers as string, return the number of ways in which the input string can be split into sub-strings and represented as character strings. For e.g. given
"111" -> "AAA", "AK", "KA" -> 3
Valid combinations are ({1,1,1}, {1,11},{11,1}) = 3
"11" -> "AA", "K" -> 2
Valid combinations are ({1,1},{11}) = 2
"123" -> "ABC", "LC", "AW" -> 3
Valid combinations are ({1,2,3},{1,23},{12,3}) = 3
You don't have to return all the mappings, only the number of valid mappings.| Report Duplicate | Flag | PURGE
Facebook Senior Software Development Engineer String Manipulation - 11of 15 votes
AnswersGiven an int array which might contain duplicates, find the largest subset of it which form a sequence.
- learner October 06, 2011 in -
Eg. {1,6,10,4,7,9,5}
then ans is 4,5,6,7
Sorting is an obvious solution. Can this be done in O(n) time| Report Duplicate | Flag | PURGE
Google Software Engineer in Test Software Engineer / Developer Arrays Algorithm - 11of 13 votes
AnswersGiven s string, Find max size of a sub-string, in which no duplicate chars present.
- sanjay05iitr November 10, 2013 in India for Cyllas Experience| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 11of 13 votes
Answersinput [2,3,1,4]
- balahana March 07, 2014 in United States
output [12,8,24,6]
Multiply all fields except it's own position.
Restrictions:
1. no use of division
2. complexity in O(n)| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 11of 13 votes
AnswersThere are some glasses with equal volume 1 litre. The glasses kept as follows
1 2 3 4 5 6 7 8 9 10
You can put water to only top glass. If you put more than 1 litre water to 1st glass, water overflow and fill equally both 2nd and 3rd glass. Glass 5 will get water from both 2nd glass and 3rd glass and so on..
- Vin July 17, 2013 in India
If you have X litre of water and you put that water in top glass, so tell me how much water contained by jth glass in ith row.
Example. If you will put 2 litre on top.
1st – 1 litre
2nd – 1/2 litre
3rd - 1/| Report Duplicate | Flag | PURGE
Amazon SDE1 - 11of 11 votes
AnswersThere are at most eight servers in a data center. Each server has got a capacity/memory limit. There can be at most 8 tasks that need to be scheduled on those servers. Each task requires certain capacity/memory to run, and each server can handle multiple tasks as long as the capacity limit is not hit. Write a program to see if all of the given tasks can be scheduled or not on the servers?
- CodeKaur August 04, 2014 in United States
Ex:
Servers capacity limits: 8, 16, 8, 32
Tasks capacity needs: 18, 4, 8, 4, 6, 6, 8, 8
For this example, the program should say 'true'.
Ex2:
Server capacity limits: 1, 3
Task capacity needs: 4
For this example, program should return false.
Got some idea that this needs to be solved using dynamic programming concept, but could not figure out exact solution.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 11of 11 votes
AnswersGiven a sequence of non-negative integers find a subsequence of length 3 having maximum product with the numbers of the subsequence being in ascending order.
- Bhavi Jagwani April 06, 2013 in India
Example:
Input: 6 7 8 1 2 3 9 10
Ouput: 8 9 10| Report Duplicate | Flag | PURGE
Amazon - 11of 11 votes
AnswersGiven an unsorted array of integers, you need to return maximum possible n such that the array consists at least n values greater than or equals to n. Array can contain duplicate values.
- abc June 20, 2014 in India
Sample input : [1, 2, 3, 4] -- output : 2
Sample input : [900, 2, 901, 3, 1000] -- output: 3| Report Duplicate | Flag | PURGE
Google Applications Developer - 11of 11 votes
AnswersGiven a string, find whether it has any permutation of another string. For example, given "abcdefg" and "ba", it shuold return true, because "abcdefg" has substring "ab", which is a permutation of "ba".
- sg March 02, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test String Manipulation