Recent Interview Questions
- 3of 3 votes
AnswersYou have a lists with integers. Find all the pairs of numbers that sum less than or equal to to a particular number k. The list contains minimum 5 Million number.
- hirajhil February 05, 2014 in United States
(I provided a n^2logn solution but they may be looking forward to having a better answer).| Report Duplicate | Flag | PURGE
Google Software Engineer Intern Algorithm - 2of 2 votes
AnswersSink Zero in Binary Tree. Swap zero value of a node with non-zero value of one of its descendants
- yuanbing January 18, 2014 in United States
so that no node with value zero could be parent of node with non-zero.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 0of 0 votes
AnswersWrite a function to validate the integrity of a binary search tree.
- floatingsms November 29, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Intern Algorithm - 1of 1 vote
AnswersSuppose there were n numbers in an array S1, S2, S3, S4.......SN rearrange them in a such a way that they satisfy bellow property.
- Rahul Sharma November 24, 2013 in United States
S1<S2>S3<S4>......| Report Duplicate | Flag | PURGE
Google Intern - 9of 9 votes
Answersyou are given n-strings 1you have to find whether a chain can be termed with all the strings given number n? A chain can be formed b/w strings if last char of the 1st string matches with 1st char of second string. For example you are given
- Rahul Sharma October 03, 2013 in India
number of strings = 3
first string=sdfg
second string=dfgs
third string=ghjhk
they can be concatenated as ->
second first third
dfgs sdfg ghjhk (characters at concatenation points are same)
so concatenated string is-dfgsdfghjhk| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - -1of 3 votes
AnswersGiven a string Sting="ABCSC" Check whether it contains a Substring="ABC"?
- Anonymous September 29, 2013 in India
1)If no , return "-1".
2)If yes , remove the substring from string and return "SC".
use very simple code and concept(ALGORITHM)..| Report Duplicate | Flag | PURGE
Facebook Front-end Software Engineer - 2of 2 votes
AnswersGiven nxn boolean matrix (0's and 1's) .
- thebiker925 September 11, 2013 in United States
Find out whether there exist a row i and column j such that
1) all elemets of row i are zero's and
2) all elements of column j are 1's and
3)(i,j)th entry of the matrix can be either 0 or 1
Find out such a i and j exist or not .
complexity :O(n)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 6of 6 votes
AnswersGiven an input array
- gowthamganguri August 30, 2013 in India
a={1,2,3,6,2,8----}
product of all numbers=p=a[0]*a[1]*---a[n-1] where n is size of array
output arrau should be b={p/a[0],p/a[1],p/a[2]-----}. you should not use division operator.Time complexity should be less than o(n2).| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 2of 4 votes
AnswersC program to Delete a node from SLL, in which the last node points to the middle node( in case of even no of nodes, it points to the first middle node) and update the SLL.
- saran August 06, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Program Manager Intern Linked Lists - -1of 1 vote
AnswersGiven a sorted array. Find the number of couples with the same difference. For example we can have an array with 2 couples whose difference is 3 and 4 couples whose difference is 5. The Output should be 2 & 4.
- chadi4all July 12, 2013 in United States| Report Duplicate | Flag | PURGE
Algorithm - 0of 0 votes
AnswersWrite a program to reverse a sentence in a zigzag order.
- Purushotham Kumar June 09, 2013 in Ireland
i/p: I am a software programmer
o/p: programmer erawtfos a ma I| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 1of 1 vote
Answersyou have a set of integers between 1 .. n in a random order with one of the numbers being repeated. find the best possible way (time and space) to obtain the repeating number.
- VJ May 06, 2013 in India| Report Duplicate | Flag | PURGE
VMWare Inc Member Technical Staff Brain Teasers - 1of 3 votes
AnswersGiven an array of both positive and negative numbers, find the contiguous range in the array which gives the maximum product. Give an algorithm which runs in O(N).
- Naveen March 15, 2013 in United States| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer / Developer Algorithm - -1of 3 votes
AnswersGave a string of characters and asked them to store in a binary search tree in such a way that it can be extracted in exactly the same order
- Bevan March 03, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 10of 10 votes
AnswersGiven a function KNOWS(A,B), which returns 1 if A knows B (and not necessarily the other way around) and 0 if A does not know B.
- asafiniu February 27, 2013 in United States
A Celebrity is one who does not know anyone,
and one who is known by everybody.
For a list of N people, find all celebrities in linear time.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 3of 3 votes
AnswersHow do you remove repeated values from a INT array, returning the resultant array in the same order as original ?
- Mauricio.Malf February 20, 2013 in Netherlands| Report Duplicate | Flag | PURGE
Booking.com Software Engineer / Developer Algorithm - 2of 2 votes
Answers1.Substring Addition
- Stephie February 19, 2013 in United States
Write a program to add the substring
eg :say you have a list {1 7 6 3 5 8 9 } and user is entering a sum 16.Output should display (2-4) that is {7 6 3} cause 7+6+3=16.| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer - 0of 2 votes
AnswersGiven n positive real numbers, find whether there exists a triplet among this set such that, the sum of the triplet is in the range (1, 2). Do it in linear time and O (1) space.
- abbi031892 February 17, 2013 in India| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer Algorithm - 0of 0 votes
Answersgiven a maze (matrix bool[N][M]) where 0 = free way, 1= obsticle - How many ways are there to reach from [0][0] to [N][M]? write a non-recursive solution.
- adam2008 February 16, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 1of 3 votes
AnswersHow can you efficiently implement three stacks in a single array, such that no stack overflows until there is no space left in the entire array space.
- alex December 13, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures - 0of 0 votes
Answersconstruct a BST given its preorder traversal. solution which i gave :-
- sameersaurav2904 November 29, 2012 in India
make first element of array as node of tree and then if element is less than root and if greater then on right. but i got the answer right for the given example but i am not sure if it was right. can you please suggest me a method to do it.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C - 0of 0 votes
Answersgiven an array of positive integers and that you are allowed to change the sign of any of the integers whenever you require.
write a program to calculate the minimum sum of this array.
the sum should be >=0.
for example :Array = {1,2,4,5} then sum = 0 as we change sign of 1 and 5{-1,2,4,-5
}
Another Example :Array = {1,2,4,5,6,17,20}, sum = 1 with {1,2,-4,5,-6,-17,20
}
- sonesh November 22, 2012 in United States| Report Duplicate | Flag | PURGE
InMobi Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou have an array of size n with values ranging from 1 to n. Exactly one number is missed and one number is repeated. Find missing number and Repeated number.
- nprabhanjan October 22, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersYou are given n dices each with heads numbered from 1 to m. You are to throw the n dices and note down the sum of the numbers on each of the n dices. You'll be give a number x and its a win if the sum obtained is greater than x. The problem is the find out the winning probability given n, m and x.
- ALgeek September 28, 2012 in India
Note 1<=n<=100,
1<=m<=10,
m<=x<=n*m.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersThere are two sets A and B with n integers, write a program to check the whether there exists two numbers a in A and b in B such that > a+b = val ( val is given );
- Anonymous September 19, 2012 in India| Report Duplicate | Flag | PURGE
Adobe - 0of 0 votes
AnswersAlice is a kindergarden teacher. She wants to give some candies to the children in her class. All the children sit in a line and each of them has a rating score according to his or her usual performance. Alice wants to give at least 1 candy for each child.Children get jealous of their immediate neighbors, so if two children sit next to each other then the one with the higher rating must get more candies. Alice wants to save money, so she wants to minimize the total number of candies.
- Nitin Gupta August 14, 2012 in India| Report Duplicate | Flag | PURGE
Algorithm Data Structures - 0of 0 votes
AnswersHow can you copy the contents of an array A to contents of Array B without using loops and any standard string copy functions
- TeachLead July 07, 2012 in United States| Report Duplicate | Flag | PURGE
Cubic Transportation Systems Limited Technical Support Engineer Arrays - 0of 0 votes
Answerswrite a pseudo code to calculate
- akash1600 July 06, 2012 in India
func(n) = 2*(func(n-1)+func(n-2)) in log(n) complexity.
Given:.func(1) = 1;func(2) = 3| Report Duplicate | Flag | PURGE
Microsoft Developer Program Engineer Algorithm