partition problem greddy approach and dynamic added