Working on algorithm problem for a coursera Algorithm's course.