First exercise from CtCI CH2. Paper implementation. Wrong on freeing.