Archives

gravatar

Blog # 86 : How to find Avg. Salary? Help them!



Five coworkers want to know what the average of all their salaries is, but refuse to reveal ANY information about their own salaries to their coworkers. How can they calculate the average ?


courtesy: Vibhaj

Click here to see the solution.
p.s. - For Remarks please hit the given link once. For Hint, hit it twice and for the solution, hit it thrice.

gravatar

Blog # 85 : Largest 100 from files


There is a big file containing 10^8 integers, one per line. Devise an algorithm to find the largest 100 integers among them. Remember you cannot read all of them into memory at once.


courtesy: Vibhaj

Click here to see the solution.
p.s. - For Remarks please hit the given link once. For Hint, hit it twice and for the solution, hit it thrice.

gravatar

Blog # 84 : Risky Bridge


A truck stops at a weigh station at the entrance to a bridge and is shown to weigh exactly 2000 lbs. The operator of the weigh station notes that the bridge can hold exactly 2000 lbs, but would crumble if it were subjected to even a fraction of an ounce more. But he says that no other vehicles ever cross over the bridge and so it's fine if the truck crosses. The truck continues on.
Once the truck is halfway across the 10-mile long bridge, a sparrow flies over to the truck and lands on the hood. The truck driver sees the bird lands and his heart drops as he realizes the bridge is about to collapse, but even after the bird lands, the bridge doesn't crumble.
How was the bridge able to hold up despite the extra weight from the bird ?




courtesy: Vibhaj

Click here to see the solution.
p.s. - For Remarks please hit the given link once. For Hint, hit it twice and for the solution, hit it thrice.

gravatar

Blog # 83 : Bitonic Array


Given an array of N distinct integers with the property that there exists an index K (0 <= K <= N-1) such that input[0], ..., input[K] is and increasing sequence and input[K], ..., input[N-1] is a decreasing sequence. Devise and algorithm to find K. Ex [1 2 4 7 10 15 13 11 5 0 -5] Answer: K=5 (input[K]=15) 


courtesy: Vibhaj

Click here to see the solution.
p.s. - For Remarks please hit the given link once. For Hint, hit it twice and for the solution, hit it thrice.

gravatar

Blog # 82 : Birthday Problem


What is the least number of people that need to be in a room such that there is greater than a 50 % chance that at least two of the people have the same birthday ?



Click here to see the solution.

Courtesy: Vibhaj Rajan
p.s. - For Remarks please hit the given link once. For Hint, hit it twice and for the solution, hit it thrice.

gravatar

Blog # 81 : Adobe Interview Questions 2012 Batch



Written Round:
1st Paper was completely a speed test.
2nd Paper had 20 question, 10 from general computer science and 10 from algorithm and data structure, few from paper 2 are below:

1. For every number that has 3 in its units place has one number which has all one's i.e. 111 that can be divided by it completely and 13 has a multiple 111111. Write a program to find such multiple for any number that has 3 at its units place.
2. write a program for checking the given number is a palindrome.
3. write a recursive program for reversing the linked list.
4. what are the maximum no of edges that can be connected in a graph of n vertices and 0 edges such that after adding edges given graph is still disconnected.
5. A question of OS on critical section.
6. write a program to return the row number which has max no of one's in an array of NxN matrix where all 1's occur before any 0's starts.
for example:
1110
1111
1000
1100
7. 1 question on deadlock and starvation
8. Given two arrays A[], B[]. Given a no. 'sum'. Find a and b such that a+b=sum ['a' from A and 'b' from B]

Technical Round 1:
1. For every number that has 3 in its units place has one number which has all one's i.e. 111 that can be divided by it completely and 13 has a multiple 111111. Write a program to find such multiple for any number that has 3 at its units place. [As I could not solve it in written round]. 
[proposed 3 different methods and their complexity]

Technical Round 2:
1. Virtual Function
2. Copy Constructor
3. Inheritance
4. Virtual Destructor
5. Suppose a Date in the format DD/MM/YYYY is palindrome, find the next palindrome date.
6. "He is a good boy" -> "boy good a is He" [He kept on adding constraints.]
7. 10 Red and 10 Blue balls are given. You have 2 jars, now a person will be picking 1 ball out of any of them. How will you maximize probability of picking Red Ball.

Technical Round 3:
1. How T9 dictionary is implemented?
2. How do Touch Phones know in which area they are touched?
3. Project info.

Technical Round 4:
1. 2 arrays A & B of numbers are given. Find combination such that a+b=c+d. [a,b from A and c,d from B] [Kept on adding constraint to minimize time and space complexity]
2. How to design a stack using 2 queues.

HR Round:
1. Tell me about yourself.
2. Why do you want to join Adobe?


Placed!

-All the very best!
Will post more as I recall them.  :)

gravatar

Blog # 80 : Simple but Tricky Sum


What would be the output of the following code ?
int main(int argc, char **argv){
printf("%d", 012345 + 123450);
return 0;
}
courtesy: Mahesh Gondi


Click here to see the solution.

p.s. - For Remarks please hit the given link once. For Hint, hit it twice and for the solution, hit it thrice.

gravatar

Blog # 79 : Strange Indian Coins


You have two Indian coins that add up to 6 rupees. However, one of them is not a 5 rupee coin.
What are the two coins ?


courtesy: Vibhaj Rajan


Click here to see the solution.
p.s. - For Remarks please hit the given link once. For Hint, hit it twice and for the solution, hit it thrice.