Yahoo Interview Questions
0of 0 votesWrite a MapReduce job that takes in two text files, and output the probability that those two files are identical (with 0% -> completely different, 100% -> completely different).
Clarification: Matching should not be a per-line diff, but it's about the content. One article could be 80 characters per line in one version, but could be 100 characters per line in another version, for the same content. In that case, it should be 100% match even though, if you are comparing line by line, they are totally different.
1of 1 votefollowing coins: half dollar, quarters,dime, nickel and penny. Print all the possible combinations of coins that will equal to one dollar.(Ex : (2) half-dollar , (4) quarter dollar etc )..
0of 0 votesIf there is a million data in file(assume integers).
The memory is enough to hold all the data.
After loading all the data into data structure , we need to insert 500 new integers after the 10000th element.
What Data structure to use and how to use?
0of 0 votesProblem Statement :
• Given an 4n X 4n Matrix, where n is a positive integer taken as input. Imagine the matrix consisting of two interleaved coils whose centers are at the centre of the matrix. Implement a java program which takes an integer (n) as input and prints the two coils in two seperate lines.
Please have a look at the below examples to get a sense of what the two coils are :
• Example 1:
• Input: 1
• Matrix:
01 02 03 04
05 06 07 08
09 10 11 12
13 14 15 16
• Output the Two Coils as:
- Coil1: 10 06 02 03 04 08 12 16
- Coil2: 07 11 15 14 13 09 05 01
• Example 2:
• Input: 2
• Matrix:
01 02 03 04 05 06 07 08
09 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64
• Output the Two Coils as:
- Coil1: 36 28 20 21 22 30 38 46 54 63 52 51 50 42 34 26 18 10 02 03 04 05 06 07 08 16 24 32 40 48 56 64
- Coil2: 29 37 45 44 43 35 27 19 11 12 13 14 15 23 31 39 47 55 63 62 61 60 59 58 57 49 41 33 25 17 09 01
-1of 1 voteSuppose there is an array with numbers :
1, 14, 5, k, 4, 2, 54, k, 87, 98, 3, 1, 32
Output for this can be assuming k =20
1,14,5,4,2,3,1,k,k,54,87,98,32
Now sort this array in a way all k are in middle and all values on left of k are smaller (in any order) and on right are larger (in any order)
Note: k is an integer value within range of 1 - 32768
Follow up: Sorting is ok. what sorting you want to use ? still is sorting necessary ? are there any other approaches ?
Follow up: Used External array with 2 pointers and 3 pointers approach. They wanted more efficient solution.
0of 0 votesHow would you design an Excel sheet's Data structure. You need to perform operations like addition. The excel sheet is very sparse and is used to store numbers in the range 1-65K. Index for a cell is known.
0of 0 votesHow to sort a 1000 GB file with ram size is 4 GB only. Which algorithm or data structure we need to use to sort these files?
Follow Up: External sort is Ok... but how can you make this solution more efficient...
Follow Up 2: Ideal chunk size for external sort (I said 512 MB based on my experience with MS Word 2013, it can not load file size >512 MB)
0of 0 votesFile-1 is having 5 million strings and File-2 is having 1 million strings. Give an Algo to remove duplicates and merge these files (Need not be sorted) into File-3.
0of 0 votesgiven m x n matrix print all the possible paths top to down.
Example
1 2 3
4 5 6
7 8 9
path for root(0,0) 1
1-4-7
1-4-8
1-5-7
1-5-8
1-5-9
similarly path for 2(0,1)
2-4-7
2-4-8
2-5-7
2-5-8
2-5-9
2-6-8
2-6-9
note- root 1 can go to middle down or right down since there is no left index available. if root element has left middle and right it can go to all those paths like 2 or 5.
follow up : provide the path which has maximum path sum.
code in java.
0of 0 votesHow would the Destructor for Singleton look like ?
dbx and how to debug a multi threaded application
Use of virtual destructor
Practical usage of STL set.
0of 0 votesI have an arrayList A which contains say 2,3,5,7,8
I have another arrayList B which contains 1, 3
Now taking the elements of B as the locations, I need to remove the elements of A present in that locations. So, basically I need to remove the element 2(position 1) and 5(position 3) from A. How to achieve it as we know that once one element got removed from an arrayList,the positions will be auto adjusted.
0of 0 votesYou are given N points in a X-Y plane. Find the two closest points out of them.
0of 0 votesGiven a few numbers, how will you push them into a stack such that whenever I pop the top most element from that stack, I get the minimum number from the bunch. Also he wanted me to tell the pop push algorithm such that the order of insertion and popping should be O(1).
0of 0 votesGiven a set of positive integers S = { a1,a2,a3,...,an} find two subsets s1 and s2 of A such that S2 = S - S1 and difference of | sum(S1) - sum(S2) | is minimum.
For example if we have a set S={12,4,7,1,6,3,3 }then S1= {12,6} and S2={ 4,7,1,3,3} such that sum(S1) - sum(S2) = 0 . It is not necessary that two subsets will always have the same sum.
0of 0 votesYou are blindfolded and placed in front a table with two jars. One jar has 50 red balls and other has 50 blue balls. What should be your strategy so that you pick up the red ball with more than 50% probability.
0of 0 votesIn 1000 wine bottles stack 10 are poisoned given 10 rats what is the minimum number of tries to find the poisoned one. Rat dies once it licks the poisoned wine.
0of 0 votesCelebrity problem:
You have a room with n people. A celebrity walks in. Everyone knows the celebrity, the celebrity knows no one. Non-celebrities may/may not know anyone in the room. Give an algorithm to find the celebrity. Discuss the complexity.
0of 0 votesThis is a very simple question. But im not sure why the answer is the way it is.
int main()
{
char *c = "abc";
*c = 'd';
printf("%s",c);
return 0;
}
What gets printed?
I said dbc for which he dint say anything and went ahead.
I coded this and found that I my compiler doesn't even give a response. I don't understand, *c sets the value being pointed to 'd' so technically this is legal right?
Can someone pitch in?
0of 0 votesDifference between == and === in JScript, Write a method to detect mouse hovering over a text box using CSS style sheets
0of 0 votesDesign a simple Address book Web application, Discuss all aspects of creating the App , starting from UI to Back-end databases
0of 0 votesDesign a client-server application in the Application layer of TCP/IP
0of 0 votesDesign mine-sweeper .
0of 0 votesWhat is Hashing.
0of 0 votesThere is external file with 5billion numbers..how will u sort
Wht if 1billion pairs?
0of 0 votesHave 5million key-value pairs wht datastruct u will use?
0of 0 votesWhat does public static void main means ..how it is called?
0of 0 votesWht is oop and comparision with traditional method.
Wht is abstraction?
Diff bet abstract class nd interface nd when u use one?
0of 0 votesA forgetful professor wants to know the names of all the students in a class of strength 'n'. For this, he makes 'm' students stand up at a time. He remembers the names of all the students who are standing and the ones who are sitting but doesn't remember the name of each student individually. He does this operation 'k' number of times and tries to infer all the names. What can be the value for 'k' when n=13 and m=5
0of 0 votesGiven an arry Arr[N] of integers and a function int func(int x) that takes an integer and returns either 0 or 1 (depending on some property of the integer). Give the most efficient algorithm to store the numbers in the array in such a way that all numbers that return 1 should come before all numbers that return 0, when called upon by the function func
0of 0 votesDesign an algorithm to sort an array whose first n-sqrt(n) elements are already sorted. What is the complexity of the algorithm.