re-engineered with vector and template for flexibility
Merge branch 'master' of https://github.com/lancebai/algorithms
tidy up