my solution for coursera-algs4 programming assignments