Author: dharam

Identify Safe Height by Dropping Eggs

Problem Statement If you have 2 eggs and you want to figure out what's the highest floor from which you can drop the egg without breaking it, how would you do it? What's the optimal solution to Identify Safe Height by Dropping Eggs? Note: For simplicity we can assume that the building is 100 floors high. Solution As any other aptitude problems let us list down what we know: The building is 100 floors high We have two eggs We can drop the eggs as many times as possible (if it is not broken in the previous drop) We understand that the question demands an optimal solution, but ...
Read More

Identify Apple and Oranges Labels

Puzzle Statement There are three boxes, one contains only apples, one contains only oranges, and one contains both apples and oranges. The boxes have been incorrectly labelled such that no label identifies the actual contents of the box it labels. Opening just one box and without looking in the box, you take out one fruit. By looking at the fruit, how can you immediately label all of the boxes correctly? Solution It might look tricky but if we can think for a while and decide upon which box to open the solution really becomes simple. Let us first note down the facts we know for sure:...
Read More

Graph Theory Applications – The Instant Insanity Puzzle

[nextpage title="Applications of Graph Theory"] Graph Theory is used in modelling and solving a lot of real world problems, games and puzzles. Here we discuss a very famous puzzle " The Instant Insanity " problem. The goal of this post is to demonstrate that such complicated problem statements can be so easily modeled and solved using Graph Theory. Also I would like to build some more  interest into Graph Theory. If you want to feel more comfortable with the basics of Graph Theory, here is a list of primers you might like to read once. Problem Definition - The Instant Insanity Puzzle The...
Read More

Priority Queues

Introduction You have N distinct jobs to process, and you are given the responsibility to schedule them on the only available job processor. New jobs keeps on getting added into the set of available jobs. Not all the jobs are to be executed as they come. There might be few which needs to be executed immediately and few can be postponed for some time. You have an efficiently algorithm to decide the priority of an incoming job. The task at hand is as follows: To schedule available jobs based on the priority assigned to them. Add new jobs to the set after assigning a priority to it. ...
Read More

Count Triangles formed by the elements of array

Problem Statement Given a sorted array of distinct integers, each of these integers can represent a length. The task at hand is to count the number of possible triangles which can be made through these lengths. Of course, if you chose one length to be one side of the triangle, you cannot use that length again in the same triangle. This means, no triangle contains the same length more than once. Important Note: For given sides of lengths a, b and c. A triangle can only be formed if sum of any two sides is greater than the third side. This is called the triangle inequality. The sum of any...
Read More