Coding 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 - -2of 2 votes
AnswerHow will you design Game of life - http://en.wikipedia.org/wiki/Conway's_Game_of_Life
- shagt March 01, 2013 in United States| Report Duplicate | Flag | PURGE
Expedia Software Engineer / Developer Coding - 1of 1 vote
AnswersYou are given two array lists. One Array List contains information of latitudes and longitudes of all the amazon stores and another array list contains all the possible values of latitudes and longitudes. Find an optimal way to find out all the latitudes and longitudes which are nearest to one pair of amazon store.
- fly123 February 02, 2013 in United States
ArrayList<latitude, longitude> AmazonStore;
ArrayList<latitude, longitude> World;| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 1of 1 vote
AnswersWrite a function that gets a number n and prints out a random list
- fly123 February 01, 2013 in United States
of numbers 1..n to the screen. For example:
randlist(5) : 1 5 3 2 4
randlist(6) : 4 6 1 5 3 2
This should be truly random (uniformly spread) and with a O(n) complexity.
Every number should appear only once. Random(n) is given as a tool you can use to generate a
single random number between 1-n| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Coding - 0of 0 votes
AnswersWrite the following function
- Phoenix February 01, 2013 in United States
void drawLine(byte[] img, int len, int wid, int r, int x1, int x2)
such that you draw a line from x1 to x2 at row r.
len is the length and wid is the width of the image/canvas.
Setting a pixel on to draw the line is to set the corresponding bit on the img array
Each byte corresponds to 8 pixels, that is each pixel is a bit in the array| Report Duplicate | Flag | PURGE
Google Developer Program Engineer Coding - 0of 0 votes
AnswersPrint all the permutaion of a given string.
- adam2008 January 29, 2013 in United States
1) explain time\space complexity?
2) how can you improve time\space complexity?| Report Duplicate | Flag | PURGE
Facebook Ebay Software Engineer / Developer Algorithm Coding - 8of 8 votes
AnswersPrint all valid phone numbers of length n subject to following constraints:
- cee.el.dg January 17, 2013 in India
1.If a number contains a 4, it should start with 4
2.No two consecutive digits can be same
3.Three digits (e.g. 7,2,9) will be entirely disallowed, take as input| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Coding - -2of 2 votes
AnswersWrite a method that takes a camilCase string as a parameter and returns underscore_case as output. Assume that input can be null or empty. If CamilCase parametar starts with a capital letter turn it into lower case without puting underscore before it. How do you test this method?
- george2515 January 11, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 2of 2 votes
AnswersWe define C(n) as the number of ways to take n identical objects out of a bucket, where objects may be taken 1, 2, or 3 at a time.
- skeptical.scientist January 05, 2013 in United States
Example: C(4)=7, because you can take 4 objects in the following 7 ways:
1,1,1,1
2,1,1
1,2,1
1,1,2
2,2
3,1
1,3
Write a function for C(n) in the language of your choice.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - -1of 1 vote
AnswersImplement a bucket fill function for a bitmap image. Assume your bitmap image is a 2-d array of integers, where each integer corresponds to a different color. bucketfill should take three inputs, newcolor, x, and y, and change the color to newcolor in the largest contiguous monochromatic region containing the point (x,y)
- skeptical.scientist January 05, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 2of 2 votes
AnswersRound 1 :
- sonesh January 03, 2013 in India
Q 2 : longest palindrome in a string ? (Need to tell in O(n) time complexity + O(1) space complexity)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Coding Dynamic Programming String Manipulation - 0of 2 votes
AnswersA log file which has user details(user ID,timestamp) and pages visited in a particular day by that user.The next day -the same kind of log file gets generated.How do you find the probability of users who logged in consecutive days out of the second day - logged in users? The question is simple,but they look for the efficient data structure and time complexity.
- sriramMS December 20, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Application / UI Design Arrays Assembly Automata Behavioral Bit Manipulation Brain Teasers C C# C++ Cache Coding Data Mining Data Structures - 0of 0 votes
AnswersPrint in spiral form as shown below
- umang.1rn09cs116 November 23, 2012 in India for Development
For n=2
3 2
0 1
For n=3
4 3 2
5 0 1
6 7 8
For n=4
15 14 13 12
4 3 2 11
5 0 1 10
6 7 8 9| Report Duplicate | Flag | PURGE
IBM Intern Coding - 0of 0 votes
AnswersGiven an integer array, convert it into a linked list with each node containing one sequence.
- manish.89july November 15, 2012 in India
Please reply on manish.89july@gmail.com| Report Duplicate | Flag | PURGE
Microsoft Applications Developer Coding - 0of 0 votes
AnswersGiven an integer array with sequence of numbers, come up with a way to compress the data without losing the information. Based on the compressed data, it should be possible to construct the original integer array.
- manish.89july November 15, 2012 in India
Please reply on manish.89july@gmail.com| Report Duplicate | Flag | PURGE
Microsoft Applications Developer Coding - 0of 0 votes
AnswersGiven an integer array, find the longest sequence and print it.
- manish.89july November 15, 2012 in India
Please reply on manish.89july@gmail.com| Report Duplicate | Flag | PURGE
Microsoft Applications Developer Coding - 0of 0 votes
AnswersFind the number of sequences in an integer array. A sequence is a list of numbers(more than one number) that comes in strict numerical order like [3, 4, 5, 6].
- manish.89july November 15, 2012 in India
Please reply on manish.89july@gmail.com| Report Duplicate | Flag | PURGE
Microsoft Applications Developer Coding - 0of 0 votes
AnswersYou are given a binary search tree T of finite (means can fit in memory) size n in which each node N contains
- mag November 09, 2012 in India
- integer data element
- pointer to left child
- pointer to right child
- pointer to in order successor (which is set null for each node)
Set all in order successor pointers of the given binary search tree.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Coding Data Structures - -1of 3 votes
AnswersGiven a number x = 0x25. Convert it into y = 0x25252525.
- Nitin Gupta November 03, 2012 in India| Report Duplicate | Flag | PURGE
Adobe Member Technical Staff Algorithm Bit Manipulation C Coding - 0of 0 votes
AnswersYou are given an input form such as the following
- panoptic.biopower November 01, 2012 in United States
(1, (2, 3), (4, (5, 6), 7))
Each element is either a number or a list (whose elements may also be numbers or other lists).
Output the numbers as they appear, stripped down into a single list.
E.G. (1, 2, 3, 4, 5, 6, 7)
(Complication - how does your code handle the case of ((((5)))) vs just ( 5 ) ? )| Report Duplicate | Flag | PURGE
Facebook Intern Coding - 0of 0 votes
AnswersYou are given a string that is in roman numeral format.
- panoptic.biopower November 01, 2012 in United States
Output the integer representation.
E.G. You're given XIV
Output 14.| Report Duplicate | Flag | PURGE
Facebook Intern Coding - 0of 0 votes
Answersimplement Java's pow function, then list test cases, examine performance, see if you can optimize performance.
- rollingstar.15 October 30, 2012 in United States for NA
public double pow(double a, int b)| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Coding - 0of 0 votes
AnswersGiven a positive integer, decode it into a string in following way :-
- @ce October 24, 2012 in India
1 - a, 2 - b,3 - c,...26 - z, 27 - aa, 28 - ab........and so on.| Report Duplicate | Flag | PURGE
Microsoft Intern Coding - 0of 0 votes
AnswersGiven today is Thursday and 23rd August, 2012. Write a function to input a date (future or past) and tell which day it is:-
- @ce October 24, 2012 in India
int day_of_week(int dd, int mm, int yyyy)
Mon -1, Tue - 2, Wed -3......Sun-7| Report Duplicate | Flag | PURGE
Microsoft Intern Coding - 0of 0 votes
AnswersGiven a matrix represented as int[n][n], rotate it 90 degrees clockwise in-place. (In-place means minimal extra memory to be used, ie, don't make a new array to copy into). Rotate clockwise means top-row becomes right-column, right column becomes bottom-row etc.
- vasan.srini October 23, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 0of 0 votes
AnswersGiven a binary tree, where each node has some value.
- freeninza October 13, 2012 in United States
Print the path with maximum value.| Report Duplicate | Flag | PURGE
Amazon Coding - 0of 0 votes
AnswersHow to calculate a mathematical expression stored as a string ? for eg :- string = "4* ( 3 + 2 ) - 1"
- karthika18ece October 04, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 1of 1 vote
AnswersA well renowned hotel has three branches in Miami. Namely x,y and z.Each has two types of customers. Regular and Rewardee. Also each branch has its own ratings x is given a 3 star rating while y has 5 star rating and z has 4 star rating.
- priya October 03, 2012 in India| Report Duplicate | Flag | PURGE
Software Engineer / Developer Coding - 0of 0 votes
AnswersDesign a Date class that represents a US date. Write add and subtract operation using the class. Optimize the operations.
- k October 03, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Coding - 1of 1 vote
AnswersGiven an array of integers [2,1,3, 5, 7, 6], re arrange elements such that either even numbers in even locations or odd numbers in odd locations. i.e [2,1,6,5,7,3] in O(n)
- bluesky October 02, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Coding