Recent Interview Questions
- 3of 3 votes
AnswersFind the k'th largest element in a binary search tree. Write code for
- jtr.hkcr March 03, 2013 in United Statesstruct Node { int val; struct Node *left; struct Node *right; } Node; Node * kth_largest(Node *root, unsigned int k);
| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Coding - 0of 2 votes
AnswersGiven a BST, print the node with value between [min, max], i.e. min = 10, max = 17, print the node with value between 10 and 17
- bskb.good February 23, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven an array elements, Find the maximum number which can be formed by the array elements
- bcsandy.1982 February 17, 2013 in India for Kindle
Eg input – a[ ] = {9,6,8,1]
Output - 9861| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 4of 4 votes
AnswersGiven a polygon with N vertexes and N edges. There is an int number(could be negative) on every vertex and an operation in set(*,+) on every edge. Every time, we remove an edge E from the polygon, merge the two vertexes linked by the edge(V1,V2) to a new vertex with value: V1 op(E) V2. The last case would be two vertexes with two edges, the result is the bigger one.
- zilchistDeepblue January 15, 2013 in United States
Return the max result value can be gotten from a given polygon.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven an array { -2 3 5 0 -3 7 -1}. Sort the array in such a way that array should contain -ve numbers first and then zero and then all +ve numbers. (Note: order of +ve number and order of -ve numbers should be same after sorting). For ex: the o/p of above array is {-2 -3 -1 0 3 5 7}
- prashaenator October 05, 2012 in India for BING| Report Duplicate | Flag | PURGE
Microsoft Developer Program Engineer Algorithm - 0of 0 votes
Answers: Design a data structure for the following operations:
- Nascent August 26, 2012 in India
I. Enqueue
II. Dequeue
III. Delete a given number(if it is present in the queue, else do nothing)
IV. isNumberPresent
All these operations should take O(1) time| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWrite an algorithm to find F(n) the number of bits set to 1, in all numbers from 1 to n for any given value of n.
- xiaoc10 March 21, 2012 in United States
Complexity should be O(log n)
For example:
1: 001
2: 010
3: 011
4: 100
5: 101
6: 110
So
F(1) = 1,
F(2) = F(1) + 1 = 2,
F(3) = F(2) + 2 = 4,
F(4) = F(3) + 1 = 5,
etc.
I can only design an O(n) algorithm.| Report Duplicate | Flag | PURGE
Amazon Algorithm - 0of 0 votes
AnswersGiven an unsorted integer array, place all zeros to the end of the array without changing the sequence of non-zero elements. (i.e. [1,3,0,8,12, 0, 4, 0,7] --> [1,3,8,12,4,7,0,0,0])
- sunghw March 15, 2012 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer Algorithm - 3of 3 votes
AnswersGiven an array A[], find (i, j) such that A[i] < A[j] and (j - i) is maximum.
- lyra_vega November 09, 2011 in -| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersDesign an algorithm to find all elements that appear more than n/2 times in the list. Then do it for elements that appear more than n/4 times.
- vikas tandi August 14, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersFind the maximum subsequence sum of an array of integers which contains both positive and negative numbers and return the starting and ending indices within the array.
- kcoder December 18, 2009
For example:
int array[] = {1, -2, -3, 4, 5, 7, -6}
The max subsquence sum is 4+5+7= 16 and start index is at 3 and end index is at 5.| Report Duplicate | Flag | PURGE
Bloomberg LP Yahoo Software Engineer / Developer Algorithm - 1of 1 vote
AnswersFind if a given integer is a power of 2.Optimize it.
- jack November 15, 2009| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Financial Software Developer Bit Manipulation - 2of 2 votes
AnswersFind the length of a linked list which contains cycle.
- test January 16, 2009| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Linked Lists - 1of 0 votes
AnswersGiven an array of positive and negative integers, re-arrange it so that you have postives on one end and negatives on the other, BUT retain the original order of appearance. For eg. 1, 7, -5, 9, -12, 15 => -5, -12, 1, 7, 9, 15
- T January 11, 2009| Report Duplicate | Flag | PURGE
Microsoft Algorithm - 0of 0 votes
AnswersHow many oranges/spheres (each of diameter 10 units) can you fit into a box with a size = 100 X 100 X 100 units.
- FinExpress October 31, 2008| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer Brain Teasers - 0of 0 votes
Answerstable RSVP
- david October 11, 2016 in United States
Name, Decision, Date
Jon, Y, 1 jan 2016
Jon, N, 2 Jan 2016
Linda, Y, 1 Jan 2016
Mark, Y, 5 Jan 2016
Rob, N, 5 Jan 2016
-- SQL query to find out how many of your friends are coming to party?, make sure that, they haven't said N after saying Y like Jon, check date.
So the answer should be 2| Report Duplicate | Flag | PURGE
ASU SQL - 5of 5 votes
Answers* Given an unsorted integer array, place all zeros to the end of the array without changing the sequence of non-zero
- haldokan August 12, 2016 in United States
* elements. (i.e. [1,3,0,8,12, 0, 4, 0,7] --> [1,3,8,12,4,7,0,0,0])| Report Duplicate | Flag | PURGE
Bloomberg LP Developer Program Engineer Algorithm - 7of 7 votes
AnswersFind missing element in the A.P.
- poojaarora014 December 22, 2015 in India| Report Duplicate | Flag | PURGE
Amazon SDET Algorithm - 2of 2 votes
Answers"Smart substring"
- ersegun August 20, 2015 in Netherlands
Write a function that takes maximum 30 characters from a string but without cutting the words.
Full description:
"Featuring stylish rooms and moorings for recreation boats, Room Mate Aitana is a designer hotel built in 2013 on an island in the IJ River in Amsterdam."
First 30 characters:
"Featuring stylish rooms and mo"
Smarter approach (max 30 characters, no words are broken):
"Featuring stylish rooms and"| Report Duplicate | Flag | PURGE
Booking.com Software Developer String Manipulation - 0of 2 votes
AnswersGiven a List of Strings, return the number of sets of anagrams.
- SK June 30, 2015 in United States
For instance, given:
<abc,cab,dac,beed,deb,few,acd>
return 5| Report Duplicate | Flag | PURGE
Google Algorithm - 0of 0 votes
AnswersGiven a array of integer and group size, reverse array by group size, example as follows:
- HBY May 08, 2015 in United States
[1, 2, 3, 4, 5, 6], 1 -> [1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6], 2 -> [2, 1, 4, 3, 6, 5]
[1, 2, 3, 4, 5, 6], 3 -> [3, 2, 1, 6, 5, 4]
[1, 2, 3, 4, 5, 6, 7, 8], 3 -> [3, 2, 1, 6, 5, 4, 8, 7]
Design test cases for you API| Report Duplicate | Flag | PURGE
Salesforce SDET Algorithm - 1of 1 vote
AnswersFind the second most repeating number in an array without using extra storage. (I had given solution using a hash table)
- xyz_coder April 02, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Intern - 5of 5 votes
Answers
- Alex March 04, 2015 in United StatesQuestion: Given two strings, find number of discontinuous matches. Example: “cat”, “catapult” Output: 3 => “CATapult”, “CatApulT”, “CAtapulT”
| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 4of 4 votes
AnswersGiven a list of strings, return a list of lists of strings that groups all anagrams.
- tirelative December 13, 2014 in United States
Ex. given {trees, bike, cars, steer, arcs}
return { {cars, arcs}, {bike}, {trees, steer} }
m = # of words
n = length of longest word
I solved this in O(m * n * log n) time.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 1of 1 vote
Answers/* In "the 100 game," two players take turns adding, to a running
- you.win September 24, 2014 in United States for Mobile
total, any integer from 1..10. The player who first causes the running
total to reach or exceed 100 wins.
What if we change the game so that players cannot re-use integers?
For example, if two players might take turns drawing from a common pool of numbers
of 1..15 without replacement until they reach a total >= 100. This problem is
to write a program that determines which player would win with ideal play.
Write a procedure, "Boolean canIWin(int maxChoosableInteger, int desiredTotal)",
which returns true if the first player to move can force a win with optimal play.
Your priority should be programmer efficiency; don't focus on minimizing
either space or time complexity.
*/
Boolean canIWin(int maxChoosableInteger, int desiredTotal) {
// Implementation here. Write yours
}| Report Duplicate | Flag | PURGE
Linkedin Senior Software Development Engineer Algorithm - 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 - 1of 7 votes
AnswersWrite a method to determine if two strings are anagrams of each other.
- nsvbry August 14, 2013 in United States
e.g. isAnagram(“secure”, “rescue”) → false
e.g. isAnagram(“conifers”, “fir cones”) → true
e.g. isAnagram(“google”, “facebook”) → false| Report Duplicate | Flag | PURGE
Google Software Engineer in Test