Follow this blog by Email

Tuesday, 23 July 2013

Towering personalities... A Puzzle.

Here is a nice programming puzzle to test - algorithm design , coding skills:
We are designing a tower consisting of people standing atop another person's shoulders. For practical reasons, each person must be both shorter and lighter than the person below him or her.
Given the heights and weights of each person in the circus, write a method to compute the largest possible number of people in such a tower, i.e. effectively the highest possible height of such human tower in number of persons.  
E.g
 Input (height, weight): (65, 100) (70, 150) (56, 90) (75, 190) (60, 95) (68, 110)
Output: The longest tower is of length 6 and includes from top to bottom:
 (56, 90) (60,95) (65,100) (68,110) (70,150) (75,190)

I will post my solution in a while.

1 comment:

Anonymous said...

A nice interview question from a famous Software development company.