Add time/space analysis.
Add recursive solution.
Refactor the code.