Recent Interview Questions
- -2of 2 votes
Answersgiven an integer array , find all combinations which sum to a given number. If a number is used once, it must not be used again.
- pooja January 31, 2016 in United States
eg if input array is 6444 and sum =10
output must be just 6 4
Give an O(n) solution| Report Duplicate | Flag | PURGE
Amazon Software Engineer Intern - 4of 4 votes
AnswersGiven a list of integers, find the highest value obtainable by concatenating these together.
- GAGA November 20, 2015 in United States
For example, given 9, 918, 917 - The answer is 9918917.
But given 1,112,113 - The answer is 1131121| Report Duplicate | Flag | PURGE
Google - 2of 2 votes
AnswersGiven a sorted array with only 0's and 1's.Count the number of 0's.
- steelrahul June 16, 2015 in India for Hyderabad
e.g: 0 0 0 0 1 1
Ans: 4.| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersMove all zeros to beginning input {1,2,3,0,0,0,4,5} output {0,0,0,1,2,3,4,5}
- dkaminfotech May 23, 2015 in United States| Report Duplicate | Flag | PURGE
Expedia SDE-2 Algorithm - 2of 2 votes
Answers0 1 ?
- .netDecoder May 08, 2015 in United States
? wildcard for 0 or 1
"01?"
010 011
Example:
01?0?
Will produce
01000
01100
01001
01101| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 2 votes
AnswersThe text of question below is exactly given by Google interviewer. So they are owner of the text and I am just quoting them. I am not the author of the text below:
- amirtar May 05, 2015 in United States
"
Imagine a museum floor that looks like this:
.#.G.
..#..
G....
..#..
G == Museum Guard
# == obstruction/impassable obstacle
. == empty space
Write a piece of code that will find the nearest guard for each open floor space. Diagonal moves are not allowed. The output should convey this information:
2#1G1
12#12
G1223
12#34
You may choose how you want to receive the input and output. For example, you may use a 2-d array, as depicted here, or you may use a list of points with features, if you deem that easier to work with, as long as the same information is conveyed.
"| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm Ideas Math & Computation - 0of 2 votes
AnswersGiven a certain range, produce all numbers in that range that fit the criteria. The criteria is as follows:
- blue60598 February 13, 2015 in United States
a number that starts with 2 of the same number, and then the sum of the previous 2 is that of the next number, and etc. For example:
112358, 121224, 448| Report Duplicate | Flag | PURGE
Epic Systems Software Developer Algorithm - 3of 3 votes
AnswersWrite a program to find pattern.
- pritishshah.it November 20, 2014 in United States
0: 1
1: 11
2: 21
3: 1211
4: 111221
5: 312211
Iterate over the previous number, and find count for same number number. Append that count before number.
e.g.,
public String pattern(int input){}
If input = 4, function should return 111221.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - -3of 7 votes
AnswersCount the number of positive integers less than N that does not contains digit 4.
- Guy January 30, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
Answersint sum = 0;
- nirupam.astro January 04, 2014 in India
for (int i = 0; i < m; i++)
for (int j = i + 1; j < n; j++)
for (int k = j + 1; k < l; k++)
sum++;
what will be the value of sum?| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersGiven n. Generate all numbers with number of digits equal to n, such that the digit to the right is greater than the left digit (ai+1 > ai). E.g. if n=3 (123,124,125,……129,234,…..789)
- codr December 26, 2013 in United States| Report Duplicate | Flag | PURGE
Epic Systems Algorithm - 0of 0 votes
AnswersGiven a number of arrays where:-
- biraja1985 December 16, 2013 in India
Arr-1={1,2,3,4,5,6,7,8,9 ... N}
Arr-2 is formed by eliminating all the elements that satisfy x*2 from Arr-1 (x belongs to natural numbers) ie.
Arr-2={1,3,5,7,9,11,13,15,17,19 ... }
Similarly Arr3 is formed by eliminating all the elements that satisfy x*3 from Arr2 (x belongs to natural numbers) i.e.
Arr3={1,3,7,9,13,1519,21,25,27 ... }
Arr-k is formed by eliminating x*k elements from Arr-(k-1).
Given number "z" and Array suffix "k" Find if z exists in Arr-k
(with as space and time minimum complexity as possible)| Report Duplicate | Flag | PURGE
Microsoft Algorithm - -1of 1 vote
AnswersComplexity of a function:
- ritujain86 November 05, 2013 in United States for Autopilot
int func_fibonacci ( int n) {
if (n < 2) {
return n;
} else {
return ( func_fibonacci(n-1) + func_fibonacci(n-2));
}
}| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 1of 3 votes
AnswersIn a Binary Tree, weight of each node is described by the value of the node multiplied by the level (i.e. for root node value is 1* value in root node), And the weight of tree is sum of all the node weights.
- prabal77 August 06, 2013 in India
Find the minimum tree weight out of all the binary trees possible from a given set of numbers.
P.S: No input and no sample data provided| Report Duplicate | Flag | PURGE
Amazon SDE-2 Data Structures - 3of 7 votes
Answersgiven an input array of integers where each integer represent the maximum amount of jump a frog can take.Frog has to reach the end of the array in minimum number of jumps.
- aka[1] August 05, 2013 in United States
Example:[1 5 4 6 9 3 0 0 1 3] answer is 3 for this.
[2 8 3 6 9 3 0 0 1 3] answer is 2 for this.
Any DP solution for this?| Report Duplicate | Flag | PURGE
Amazon Applications Developer Algorithm - 0of 4 votes
AnswersGiven - a number (n) and a sorted array
- LAP July 07, 2013 in United States
Find a number in the array having least difference with the given number (n).| Report Duplicate | Flag | PURGE
Facebook Intern Algorithm - -3of 3 votes
AnswersYou have an array of binary numbers as "00001101000001010100000..."... We need to find the First occurrence of 1 in this series.. using binary search.
- imvrajendra May 21, 2013 in India
we need to design an algorithm of complexity less than O(n).. and we need to use binary search strictly..| Report Duplicate | Flag | PURGE
Amazon SDE1 Arrays - 2of 2 votes
AnswersSort an array which only has 0's and 1's. Do not use count sort.
- CodeNameEagle May 10, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm Arrays - 2of 2 votes
AnswersGiven a binary tree, print its perimeter:
- JSDUDE May 04, 2013 in United States
node, left->most nodes from top to bottom, leaf nodes from left-> right, right->most nodes from bottom to top
----------------------------1
-----------------------2--------3
------------------4-----5-----6--------7
-------------8------9-----10------11-----12
should print:
1-2-4-8-9-5-10-11-12-7-3
5 because it doesn't have any children. 10 and 11 are children of 6 and 8 & 9 are children of 4.
Apologies for the messy diagram.| Report Duplicate | Flag | PURGE
Microsoft SDE1 Trees and Graphs - 2of 4 votes
AnswersHow do you find the greatest 1000 elements in a list of a million elements? No other information given. What would be the runtime? Hint: You can do better than O(n log n). I didn't realize but it could be possible with Tree or Heaps.
- Ana April 23, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersAppend the last n nodes of a linked list to the beginning of the list
- ruddermechanic February 07, 2013 in India
eg: 1->2->3->4->5->6
if n=2
5->6->1->2->3->4| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Linked Lists - 0of 0 votes
AnswersWhich is best data structure among following for recursion?
- Droid February 06, 2013 in United States
Array
stack
queue
linked list| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersYou have given an array of Integers of size n, and a sliding window by 1 integer ,of size k <= n. you have to print minimum number in each window of size k.
- pandu.vdp January 30, 2013 in India
E.g: given array [3,9,0,3,18,6], i.e.n = 6 and window size k = 3
available windows for above array is [3,9,0] ,[9,0,3],[0,3,18], [3,18,6]
output should be : 0, 0, 0,3| Report Duplicate | Flag | PURGE
Chronus Java Developer Data Structures - 0of 0 votes
Answers2.Given an integer linked list of which both first half and second half are sorted independently. Write a function to merge the two parts to create one single sorted linked list in place [do not use any extra space].
- kumar.prince6 January 13, 2013 in India
Sample test case:
Input: List 1:1->2->3->4->5->1->2; Output: 1->1->2->2->3->4->5
Input 2: 1->5->7->9->11->2->4->6; Output 2: 1->2->4->5->6->7->9->11
C/C++/Java/C#
struct node
{
int val;
node *next;
}
node* sortList(node* list1) {
}
Java
class Node
{
int val;
Node next;
}
Node sortList(Node list1) {
}| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersArray on integer is given
- MI December 17, 2012 in India
find out next bigger number
Ex {2,5,3,4,61}
Out: 2->5
5->6
3->4
4->6
6->-1 //not possible
1-> -1 //not possible| Report Duplicate | Flag | PURGE
Amazon - 1of 1 vote
Answersgenerate permutations of a string without duplicates and without using hashtable to memorize the permutations.
- Andi December 05, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGive a BST and a number. we need to find next bigger number in BST.
- Harsh123 November 04, 2012 in India for Kindle| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Data Structures Trees and Graphs - 0of 0 votes
AnswersGiven a matrix with 1's and 0's, find the number of groups of 1's. A group is defined by horiz/vertically adjacent 1's.
- Steve October 16, 2012 in United States| Report Duplicate | Flag | PURGE
Google Algorithm - 0of 0 votes
AnswersJust got out of my interview realizing how ridiculously stupid I answered this question. The question was there is an array of positive and negative integers. Write an algorithm to find the subsequence with largest sum of integers in this array. Also, I can not return the entire array, even if it makes the largest sum. If the largest sum is less than -1, throw an exception.
- sameer.doha September 07, 2012 in United States
I made the mistake of ignoring negative numbers, thinking it would decrease my sum. :(| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays - 1of 1 vote
Answersfind longest increasing sub sequence in 2d array.
- nagyuga August 22, 2012 in United States
(bit more expl..)
ex: finding length of the snake in snake game
---------
the sequence must not be diagonally.
but it can be any like top-bootm,bottom-left-top ........
increasing means one step
ex: 10,11,12,13 (correct)
12,14,15,20(wrong)
Ex: input: consider 4x4 grid
2 3 4 5
4 5 10 11
20 6 9 12
6 7 8 40
output : 4 5 6 7 8 9 10 11 12| Report Duplicate | Flag | PURGE
Epic Systems Software Development Manager Algorithm