Recent Interview Questions
- -1of 1 vote
Answerswe have given char array like “a1b2c3″ we have to convert this array to array like this “abbccc”. Can someone share the program please
- vaishali.sankar May 24, 2015 in United States| Report Duplicate | Flag | PURGE
- 0of 0 votes
AnswersGiven a Binary search tree of integer values. return the count of nodes where all the nodes under that sub-tree lies between a given range [x, y]. assume there are more than 100,000 nodes
- solxget April 24, 2015 in United States| Report Duplicate | Flag | PURGE
Google SDET - 6of 6 votes
AnswersGiven an array such that every next element differs from the previous by +/- 1. (i.e. a[i+1] = a[i] +/-1 ) Find the local max OR min in O(1) time. The interviewer mentioned one more condition that the min or max should be non-edge elements of the array
- xyz March 30, 2015 in United States
Example: 1 2 3 4 5 4 3 2 1 -> Local max is 5
1 2 3 4 5 -> No local max or min exists
5 4 3 2 1 -> No local max or min exists| Report Duplicate | Flag | PURGE
Facebook Software Developer Algorithm - 3of 5 votes
AnswersA robot has to move in a grid which is in the form of a matrix. It can go to
- thisandthat March 09, 2015 in United States
1.) A(i,j)--> A(i+j,j) (Down)
2.) A(i,j)--> A(i,i+j) (Right)
Given it starts at (1,1) and it has to go to A(m,n), find the minimum number of STEPS it has to take to get to (m,n) and write
public static int minSteps(int m,int n)
For instance to go from (1,1) to m=3 and n=2 it has to take (1, 1) -> (1, 2) -> (3, 2) i.e. 2 steps| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 2of 2 votes
Answersgiven a vector of integers, v[i] represent the stock price on day i. Now you may do at most K transactions. you must sell your stock before you buy it again and that means you can NOT have two stocks at the same time. write a program to find max profit you can get.
- rjrush December 17, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersWrite code to sum 2 integer but u cant use a+b method, you have to use either ++ or --. How you will handle negative numbers.
- newbee October 10, 2014 in United States| Report Duplicate | Flag | PURGE
Apple Software Engineer in Test Algorithm - 0of 0 votes
AnswersAn array contain 6 different numbers, only 1 number is repeated for 5 times. So now total 10 numbers in array, Find that duplicate number in 2 steps only?
- gdg August 03, 2014 in United States| Report Duplicate | Flag | PURGE
Yahoo - 0of 4 votes
AnswersGiven a linked list with next and high pointers, populate high pointers to the next higher node, inplace and O(n).
- HardCode May 13, 2014 in India| Report Duplicate | Flag | PURGE
Microsoft Linked Lists - 3of 5 votes
AnswersThere is a village in which parent prefer to have at least 1 boy. So they keep doing child until they get their first boy and then they stop doing children. What is ratio of girl/boy in such town after infinite years.
- shivam.s.kalra March 13, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Automata - 0of 0 votes
AnswersFind the maximum-sum subarray of an array.
- floatingsms November 29, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Intern Arrays - 0of 2 votes
AnswersYou are given an array in which you’ve to find a subarray such that the sum of elements in it is equal to zero.
- ninja October 02, 2013 in -| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 4of 4 votes
AnswersWe are given a set of integers with repeated occurences of elements. For Example, S={1,2,2}.
- sc.shobhit September 14, 2013 in India
We need to print the power set of S ensuring that the repeated elements of the power set are printed only once.
For the above S, the power set will be {NULL, {1}, {2}, {2}, {1,2}, {1,2}, {2,2}, {1,2,2}}. So, as per the question requirements, we need to print {NULL, {1}, {2}, {1,2}, {2,2}, {1,2,2}}| Report Duplicate | Flag | PURGE
Facebook Intern Algorithm Coding Trees and Graphs - 0of 4 votes
AnswersWrite a function to search for the existence of a string (target) in another string (str). The function takes two strings as the input and returns the index where the second string is found. If the target string cannot be found, then return -1
- Rahul June 18, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer String Manipulation - 0of 0 votes
Answers[Question asked during online Test.]
- Rahul June 18, 2013 in India
Given a list of 'N' coins, their values being in an array A[], return the minimum number of coins required to sum to 'S' (you can use as many coins you want). If it's not possible to sum to 'S', return -1
Sample Test Cases:
Input :
Coin denominations: { 1,3,5 }
Required sum (S): 11
Output :
3| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWrite a Method in Java which takes an Array of strings and from the array of strings returns only those strings which have a consecutive repetition of a particular letter for eg: if I/P is {"Dauresselam", "slab", "fuss", "boolean", "clap"}
- Anirudh May 28, 2013 in United States
then O/P should be {"Dauresselam", "fuss", "boolean"}| Report Duplicate | Flag | PURGE
Ibibo Testing / Quality Assurance Arrays - 1of 1 vote
AnswersCode to check if a given short string is a substring of a main string. Can you get a linear solution (O(n)) if possible?
- Jeanclaude May 18, 2013 in United States for Office| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test String Manipulation - 3of 3 votes
AnswersWrite a program to sort an array of strings so that all anagrams are next to each other
- Neo March 07, 2013 in United States for Web Service
ex
input {god, dog, abc, cab, man}
output {abc, cab, dog, god, man}| Report Duplicate | Flag | PURGE
Amazon Intern C++ Java - 2of 2 votes
AnswersAssume I have a log file with list of people with their arrival and departure time at an event that happened in the past.
- Bevan March 02, 2013 in United States
My task is to find out the maximum number of people present at any time during the entire event? I am not given query time.
ai = Arrival time of person i
di = Departure time of person i
I have a list of pairs like (a1,d1), (a2,d2), (a3,d3).... (an,dn)... It's not in a database.
I apologize as I cannot edit my previous question. I think it had a incomplete description.
Please let me know if you guys still need clarification. Thanks| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou have a two dimensional array of size m*n. The
- charan January 08, 2013 in United States
elements in the rows are sorted and every row has
unique elements means( in a row no two elements are same) but
the elements can repeat across the rows.
For example:
you have following 2-D array:
{
2 5 7 9 14 16
3 6 8 10 15 21
4 7 9 15 22 35
7 8 9 22 40 58
}
You are supposed to write an efficient function which
will take upper 2-D array as input and will return a
one-dimensional array with following properties:
a) the 1-D array must contain all the elements of above
2-D array.
b) the 1-D array should not have any repeated elements.
c) all the elements should be in sorted order.
For example:
for the above 2-D array, the output should be:
A [ ] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16, 21, 22, 35,
40, 58 }
Function Prototype should be :
int [ ] MergeAndSort( int[ ][ ] inputArray )| Report Duplicate | Flag | PURGE
Amazon - 1of 1 vote
AnswersThere are two gates , one to hell and the other to heaven.
- Buzz Lightyear November 22, 2012 in India
Two gatekeepers , one for each gate.
One of them always speaks the truth and the other always lies but you don't know which one s guarding which gate.
You are allowed only one question and you need to find out the gate to heaven.
What is the question you will ask and remember , you do not know which one speaks the truth and which one lies.| Report Duplicate | Flag | PURGE
Brain Teasers - 0of 0 votes
AnswersThere is a sorted array of infinite numbers (can contain duplicates). Given a number. Find the last occurring instance of that number in the array.
- Rahul November 21, 2012 in India for Kindle
Ex., i/p: 12344445566667789...
search number: 6
o/p: 12 (index)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWrite an algorithm to print out how many extra duplicates there are in a binary search tree.
- sjs3 November 01, 2012 in United States for amazon local
input 1:
2
/ \
1 2
output 1:
2 1
input 2:
3
/ \
2 3
/ \ \
1 2 4
/ \
3 4
\
5
\
5
output 2:
2 1
3 2
4 1
5 1
Given:
Node {
int value;
Node left;
Node right;
}| Report Duplicate | Flag | PURGE
Amazon Trees and Graphs - 0of 0 votes
Answerswe have an array, and a window of k elements
- Biswajit Sinha September 09, 2012 in United States
which slides over n elements of array A
k<n
we need to construct array B
such that B[i] = min (A[i], A[i+1]....A[i+k-1])
we don't have additional space at all
and we need to work on a solution better then O(nk)
say n = (1,1,2,3,4,5)
k =2
b would be (1,1,2,3,4)
if k=3
b would be (1,1,2,3)| Report Duplicate | Flag | PURGE
Algorithm - 0of 0 votes
AnswersUser inputs a series of numbers and terminates the series by a zero. Your program should find the first three maximum values in the series and exclude them from the series and compute the average of the remaining numbers. (excluding zero as well)
- ranechabria July 14, 2012 in United States
Ex - 3, 7, 12, 2, 25, 8, 9, 13, 10, 0
First three maximum numbers = 25, 13, 12
Average of the rest = (3 + 7 + 2 + 8 + 9 + 10) / 6 = 6.5| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Algorithm Coding - 1of 1 vote
AnswersWrite a program to generate all palindrome dates by taking the beginning and the ending dates as an input from the user. The format of the date is given as MMDDYYYY.
- lucky March 21, 2012 in United States| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou are given an unsorted array with both positive and negative elements. You have to find the smallest positive number missing from the array in O(n) time using constant extra space.
- ashu February 19, 2012 in India
Eg:
Input = {2, 3, 7, 6, 8, -1, -10, 15}
Output = 1
Input = { 2, 3, -7, 6, 8, 1, -10, 15 }
Output = 4| Report Duplicate | Flag | PURGE
InMobi Algorithm - 1of 1 vote
AnswersGiven a matrix, whose rows and columns (n * n) are sorted. Given a number x, find whether it exists in the matrix. (I told him the O(n) algo, but he wanted a log n solution)
- P January 22, 2012 in India for Bing| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer