Recent Interview Questions
- 2of 2 votes
AnswersLength is given as input.Print all possible permutations of numbers between 0-9.
- bhavanisankara March 17, 2013 in United States
Eg: if input length=4
all possible combinations can be 0123, 1234, 5678,9864,...etc all combinations of length from in all numbers between 0-9| Report Duplicate | Flag | PURGE
Epic Systems Arrays - 1of 1 vote
AnswersIn a series of 1 to N, two numbers are missing. Find the missing numbers? Quickest way?
- xankar March 16, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Algorithm - 1of 1 vote
AnswersWrite a program to sum two binary numbers represented as strings.
- rodrigoreis22 February 11, 2013 in United States
Input: "110", "01101"
Output: "10011"
Method signature:
public String addBinaryNumbers(String num1, String num2);| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven two linked lists combine them in a way such that the resultant must contain the elements alternatively from one list and the other list?
- Ashish January 31, 2013 in India
For ex.
LL1 : 1->2->3->4
LL2 : 5->6->7
Result : 1->5->2->6->3->7->4
Also provide test cases for the algorithm ?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Linked Lists - 0of 0 votes
Answersgiven an ASCII string, return the longest substring with unique characters. Ex: dabcade => Ans: bcade.
- bharat November 16, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 1of 1 vote
AnswersGiven 2 arrays A,B, where x(A.length) < y(B.length), we want to
- An0nemous October 08, 2012 in -
insert (y - x) 0's to A at various places such that A*B is minimum. For instance, if A = (1, -1) and
B = (1,2, 3, 4), then inserting two 0's in the middle of A such that A = (1, 0, 0, -1) would minimize
A*B. I think he was looking for a dynamic problem solution.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersFind the minimum element in a stack in O(1) time complexity and O(n) space complexity
- debajyoti2510 August 04, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Stacks - 0of 0 votes
AnswersGiven an array of integers, return the first integer which occurs only once in O(n).
- Evan May 01, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures - 0of 0 votes
AnswersGiven a binary search tree of n nodes, find two nodes whose sum is equal to a given number k in O(n) time and constant space
- dev February 19, 2012 in India
I cud think of this algo..Do two inorder traversals, one in the usual (descend to the left
before descendung to the right) direction and the other in the
reversed(descend to the right before descending to the left)
direction.and compare the sum with x..
But i am unable to code it properly..(in C)
Need help| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
Answersn numbers (both +ve and -ve) are arranged in a circle. find the maximum sum of consecutive nos. Do this in O(n) time
- pavel.em February 06, 2012 in United States
E.g.: {8,-8,9,-9,10,-11,12}
max = 22 (12 + 8 - 8 + 9 - 9 + 10)| Report Duplicate | Flag | PURGE
Microsoft Algorithm - 2of 2 votes
Answersyou have given 2n+1 numbers in which 2n numbers are repeated means every number is having duplicate value.find that non repeating number in constant space and o(n) time.i told him using XOR.
- time February 03, 2012 in India
then he gave me 2n+2 numbers in which 2n numbers are repeating like above now you have 2 different number.find both number in constant space and o(n) time.(f2f 4th round)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersHow do you find a shortest connection between two persons on Facebook(if the same exists)?
- shwetank2003819 November 28, 2011 in India
You are provided with an API which returns the list of friends of a particular persons| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersGiven a doubly linked list containing only three integers 1,2,3. Sort the list without exchanging the values.
- Puzzle November 19, 2011 in India
Eg- 1->3->2->1->2->3->2->1->1
output: 1->1->1->1->2->2->2->3->3| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Data Structures Linked Lists - 0of 0 votes
AnswersGiven an array A[] and a integer num. Find four no.s in the array whose sum is equal to given num.
- Abhi August 26, 2011
Brute force :- O(n^4)
I solved it in O(n^3)
But the interviewer was insisting on a better solution.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersCard shuffle problem. I have a card pack of 313 cards. I remove the topmost card from card pack and place it on desk and I remove the next one and put it below the pack of cards(that you are holding). keep doing this till all the cards are on desk. Pick up the card stack from desk and repeat these steps till you find retrieve the original cards orderd. I was asked to code to find how many rounds it will take to retrieve initial order.
- puzzle_math February 17, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersCheck if two given strings are anagrams?
- CGB (2nd Telephone Interview) February 14, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer String Manipulation - 0of 0 votes
AnswersGiven a number find whether the digits in the number can be used to form an equation with + and '='. That is if the number is 123, we can have a equation of 1+2=3. But even the number 17512 also forms the equation 12+5=17.
- Amit November 08, 2010| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou are given a sorted array such that all the number is repeated except one.
- Nitin October 30, 2010
Find that non repeated number in O(n)| Report Duplicate | Flag | PURGE
Amazon Algorithm - 0of 0 votes
Answersif a clock looses 2 secs per day, how much time will it loose in 2 days ?
- MrNonMadison February 03, 2010| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Brain Teasers - 0of 0 votes
AnswersWrite an algorithm to find the number of six digit numbers where the sum of the first three digits is equal to the sum of the last three digits.
- gar November 17, 2009| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven a variation of a binary tree(not BST) in which each node has a parent, left and right pointer. The nodes do not have any key elements or any other data to identify itself. The root is the node that has a null parent pointer. You are given the pointers to two random nodes in the tree which may or may not be at the same level. Find the first common ancestor to the two random nodes given in the tree.
- Anonymous November 16, 2009| Report Duplicate | Flag | PURGE
Amazon Microsoft Software Engineer / Developer Trees and Graphs - 1of 1 vote
AnswersWrite a progam to rotate a matrix by 90 degrees.
- Devil170 February 28, 2009| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Matrix - 0of 0 votes
AnswersHow many ways can you paint a cube if you have three colors of paint?
- Ravi Kant Pandey March 30, 2007| Report Duplicate | Flag | PURGE
Infosys Software Engineer / Developer Brain Teasers - 0of 0 votes
AnswersYou have a basket ball hoop and someone says that you can play 1 of 2 games. You get $1000 and one shot to get the hoop. Or, you get three shots and you have to make 2 of 3 shots. Which one do you choose? If p is the probability of making a particular shot, what value of p makes you switch games?
- Gayle L McDowell April 04, 2005| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Math & Computation - 2of 2 votes
AnswersGiven a string s contains lowercase alphabet, find the length of the Longest common Prefix of all substrings in O(n)
- Prateek Agrawal December 02, 2018 in United States
For example
s = 'ababac'
Then substrings are as follow:
1: s(1, 6) = ababac
2: s(2, 6) = babac
3: s(3, 6) = abac
4: s(4, 6) = bac
5: s(5, 6) = ac
6: s(6, 6) = c
Now, The lengths of LCP of all substrings are as follow
1: len(LCP(s(1, 6), s)) = 6
2: len(LCP(s(2, 6), s)) = 0
3: len(LCP(s(3, 6), s)) = 3
4: len(LCP(s(4, 6), s)) = 0
5: len(LCP(s(5, 6), s)) = 1
6: len(LCP(s(6, 6), s)) = 0
String contains only lowercase alphabates.| Report Duplicate | Flag | PURGE
Google SDE1 Data Structures - 1of 1 vote
AnswersGiven an array of sorted integers and find the closest value to the given number. Array may contain duplicate values and negative numbers.
- Vijay November 17, 2017 in India
Example : Array : 2,5,6,7,8,8,9
Target number : 5
Output : 5
Target number : 11
Output : 9
Target Number : 4
Output : 5| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm Arrays Coding Data Structures - 2of 2 votes
AnswersGiven an array of integers greater than zero, find if it is possible to split it in two (without reordering the elements), such that the sum of the two resulting arrays is the same. Print the resulting arrays.
- eo March 21, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook Production Engineer Coding - 1of 1 vote
AnswersYou are given a string "abc" which is encoded like "123" where alphabets are mapped like a => 1 to z => 26. Now find out how many string can be formed by reverse engineering encode string "123".
- sachin323 May 16, 2016 in United States
For ex. given string "123" we can form 3 string "abc"(1,2,3), "lc" (i.e 12,3), "aw"(1,23).
for string "1234" we have following possible combinations, I might be missing some of them but you get the idea
{12, 3, 4}
{1, 23, 4}
{1, 2, 3, 4}| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm