some new methods for 1007
dynamic programming for 1007