Recent Interview Questions
- 0of 0 votes
AnswersArrayList A, B, C are sorted int arraylists.
- hboy December 29, 2012 in United States
When A[i] + B[j] = C[k], you need to remove C[k] from ArrayList C.
Please implement code with O(N^2). Note that you are not allowed to use additional data structures such as arrays, hash tables, etc.| Report Duplicate | Flag | PURGE
Ebay Software Engineer / Developer Arrays - 0of 0 votes
AnswersWrite a function to check whether the two strings are rotation of each other or not.
Example: str1="Password" str2="ordPassw"
My Solution was.........
- varunesh.88 December 07, 2012 in India#include<stdio.h> void fn(char * str1, char * str2) { int i=0, j=0,flag=0; while(str2[i]) { if(str2[i]== *str1) { flag=1; break; } i++; } if(!flag) { printf("2nd String is not a rotation of other\n"); return; } j=i; while(str2[i]) { if( !(str2[i]==*str1)) { printf("2nd String is not a rotation of other\n"); return; } i++; str1++; } i=0; while(i<j) { if( !(str2[i]==*str1)) { printf("2nd String is not a rotation of other\n"); return; } i++; str1++; } if(*str1=='\0') printf("String are rotation of each other\n"); else printf("2nd String is not a rotation of other\n"); } int main() { char * str1="Password"; char * str2="ordPassw"; fn(str2, str1); return 0; }
| Report Duplicate | Flag | PURGE
Morgan Stanley Intern C - 0of 0 votes
AnswersI need to insert an element in a heap, making sure that it does not already exist in it. Can this be done in O(logn) time?
- artemis November 25, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou are given 2 fair dices, whose all 6 faces are blank. You have to fill these faces with 0-9(you can repeat some digits, as there are 12 faces) such that, you should be able to produce all the dates of an English month.
- explorer.bit November 14, 2012 in India
e.g. you should be able to show 01 02 ....09 10.....30 31| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Brain Teasers - 1of 1 vote
AnswersWe have n number of sorted array for fixed length.
- Harsh123 November 04, 2012 in India for Kindle
Now we have to merge these and need to save finaly result array into given array.
Note- we can't use extra space except the given array.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays Data Structures Sorting - 2of 2 votes
Answersgiven y bytes and you can transfer only x bytes at once..give a mathematical expression having only + - / * which gives the number of iterations to copy y bytes. ( dont try giving modulo operator answers )
- rahulbmv October 25, 2012 in United States| Report Duplicate | Flag | PURGE
NVIDIA Software Engineer / Developer Algorithm - 1of 1 vote
AnswersFind the angle between minute and hour hand when time is 6:50 am
- crystal.rishi2 October 23, 2012 in India| Report Duplicate | Flag | PURGE
Kalido Software Engineer / Developer Brain Teasers - 0of 0 votes
AnswersTwo elements of BST are swapped by mistake. You have to restore the tree without changing its structure.
- Nascent August 30, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersThere are n frames of m data element each. The data element in each frame is arranged in increasing order. You are provided m*n space in which you have to arrange all data in increasing order.
- Anonymous August 27, 2012 in India
Time:O(n)
Space:O(1)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWhat is the next number in the series
- DashDash May 12, 2012 in India
2,4,8,16,24...| Report Duplicate | Flag | PURGE
Goldman Sachs Applications Developer Brain Teasers - 0of 0 votes
AnswersGiven N points(in 2D) with x and y coordinates. You have to find a point P (in N given points) such that the sum of distances from other(N-1) points to P is minimum.
- Learn Android: http://learnandroideasily.blogspot.in/ April 24, 2012 in India| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer Algorithm - 0of 0 votes
AnswersImplement a stack with 3 operations: push, pop and findmiddle(). At any point in time, findmiddle() should return the middle element of the stack (n/2+1) without popping out the elements. ie. in O(1) time
- ps April 20, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 0of 0 votes
AnswersWe have n punching bags in a row. Mr Lee is going to practice with them for the upcoming Boxing tournament.
- jinalshah2007 April 14, 2012 in United States
Each bag has a resistance level. Mr Lee can punch a bag if its resistance is greater than 0. He is an extremely hard puncher: when Mr Lee punches a bag, not only is its resistance set to 0 (ie: the bag is destroyed), but also the resistances of its immediately adjacent neighbors( one on left and other on right ) are decreased by one. If at any point of time the resistance of a bag drops to zero or less it is considered as destroyed. A punch on a bag with resistance greater than 0 has no impact on an immediate neighbour which is already destroyed.
Mr Lee wants to maximize his (very expensive) workout sessions, and would like to punch on these bags as much as possible. For any set of punching bags, what is the maximum number of punches that he can perform?
Input Format
On the only line of input there are n characters describing the resistances of the bags from 1 to n.
Ouput Format
On the only line of the output print an integer describing the maximum number of punches Mr Lee can punch for that set of bags.
Sample Input
11
Sample Ouput
1
Sample Input
021
Sample Output
2
Explanation
In the first example there are two bags, and we can punch only one of them before destroying both. In the second example we can punch on the third bag and then on the second bag to obtain two punches.
Constraints
Each bag has a resistance level between 0 and 3 ( inclusive ) and the number of bags is not more than 100.| Report Duplicate | Flag | PURGE
Algorithm - 0of 0 votes
AnswersWithout using /,% ,+and * operators. write a function to check whether a number is divisible by 3 or nor??
- abhishek April 12, 2012 in India| Report Duplicate | Flag | PURGE
Adobe Coding - 0of 0 votes
AnswersWrite a Program
- abcabc April 09, 2012 in United States
You will create an employee class with the following properties:ID (int), FName(string), LName(string).
(Functionality) to track an employee's manager and subordinates.
Add a method that displays the names of all subordinates for a given employee.
Calculate the complexity. Do not use multiple classes.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Java - 2of 2 votes
AnswersGiven N pair of parenthesis. Write an algorithm which would print out all possible permutations possible with those parenthesis given that parenthesis are in correct order (i.e. every open parenthesis is matched with closed parenthesis)
- shadykiller March 06, 2012 in India
For .e.g. .. N =3 should give:
()()()
(()())
()(())
(())()
((()))| Report Duplicate | Flag | PURGE
Flipkart Algorithm - 0of 0 votes
AnswersYou are given a function printKDistanceNodes which takes in a root node of a binary tree, a start node and an integer K. Complete the function to print the value of all the nodes (one-per-line) which are a K distance from the given start node in sorted order. Distance can be upwards or downwards.
- Novice Coder January 31, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 0of 0 votes
Answersgiven a 10 digit number,find the greatest continuous 4 digit number.
- tejaswibm December 22, 2011 in India
Ex:9164352435
Ans : 9164| Report Duplicate | Flag | PURGE
Iron Mountain Software Engineer / Developer C++ - 0of 0 votes
AnswersYou have two arrays A and B of strings. In the array B all element are from A except one. ex:
- sonali.kapor007 November 17, 2011 in India
A = {"abc", "bcd", "dpr"};
B = {"abc", "mnp", "bcd", "dpr"};
You have find out the string which is extra in B in O(n) time.
In the above example it is "mnp".| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWrite a program / Aggorithm to solve generalized M liter and N liter Jug problem which will tell to the user whether K liter is possible or not from the M and N .
- Nitin September 21, 2011 in -
For Example :-
M=3 and N=4 and K=5 . Its possible to produce 5 liter with the help of 3 and 4 liter . He wanted to have a running algo/code for the same .| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersGiven an array of strings of 0s and 1s. X and Y are also given. Return the maximum number of elements in a subset of the array elements which will X number of zeroes and Y number of 1s when combined. For eg: if array[] = {"01", "10", "0", "110"} X=3, Y=2
- controlc September 18, 2011 in India
Answer should be 3 since first 3 strings when combined will give the required number of 0s and 1s.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersAdd two big numbers represented as link lists without reversing the link lists.
- Saurav July 21, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven a binary tree, find 2 leaf nodes say X and Y such that F(X,Y) is maximum where F(X,Y) = sum of nodes in the path from root to X + sum of nodes in the path from root to Y - sum of nodes in the common path from root to first common ancestor of the Nodes X and Y
- jobseeker June 16, 2011| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersDesign a Data Structure with following operations
- pradeep April 11, 2011
1.Insert(X) -> insert X if X not present
2.Delete(X) -> delete X if X present
3.Get() -> return any element if it is present
all operations in O(1).
No memory constraint.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersInput: A unsorted array of size n.
- Ram January 02, 2011
Output: An array of size n.
Relationship:
> elements of input array and output array have 1:1 correspondence.
> output[i] is equal to the input[j] (j>i) which is smaller than input[i] and jth is nearest to ith ( i.e. first element which is smaller).
> If no such element exists for Input[i] then output[i]=0.
Eg.
Input: 1 5 7 6 3 16 29 2 7
Output: 0 3 6 3 2 2 2 0 0| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 2 votes
AnswersGiven n stairs, how many number of ways can you climb if u use either 1 or 2 at a time?
- Anonymous August 24, 2010| Report Duplicate | Flag | PURGE
Morgan Stanley Software Engineer / Developer