Rod-Cutting-Algorithm simple algorithm for finding optimal solution using dynamic programming and memoization