LET'S TALK TECHNICAL

This blog is intended to help people prepare for the job interviews and improve their analytical skills. We have posted difficult datastructures and algorithm questions and puzzles. Interview experiences section is for the people to post their interview experiences.Views expressed here are of their personal and the blog author doesn't take any responsibility for the same.

-

Followers

Jobs

Saturday, March 27, 2010

given 2 non-uniform ropes (each burns down in 1hr, but not uniformly), how to measure 45 mins

Ignite one rope on both the ends. Ignite the second rope at only one end. When the first rope burns out, it is 30 mins. Then ignite the unburned end of the second rope. When the remaining rope burns out, it is another 15 mins. So it is 45 mins.

Sunday, March 21, 2010

Find next number in Sequence

you have a sequence where each number is a multiple of 2 or 5 (so: 2^i * 5^j). Given the beginning of the sequence as 1,2,4,5,8,10,16... and find a algorithm to calculate the next number in the sequence?

Answer:
This answer gives u the pattern to make the sequence. Algorithm would look like this.
1. Make set1 with all powers of 2(i.e 2,4,8,...)
2. Make set2 with all powers of 5(i.e 5,25,125 ...)
3. Make set3 with product of numbers from set1 and set2(i.e 10,20,40,50,80,100 etc..)
Make sure that third set is sorted.
Now display elements from set1 till u find a element less than starting element in set2 or set3. Otherwise display minimum element out of elements from set2 or set3.

Popular Posts