added a library implementation of this problem for comparison ..