Recently solved problem #3752 - JEDNAKOS.
If you want to solve the problem yourself - stop reading now.
Solution - Recursion + Memoization
If you want to solve the problem yourself - stop reading now.
Solution - Recursion + Memoization
Easy problem really
1) Treat numbers starting with zero as special cases.
1) Treat numbers starting with zero as special cases.
2) Let minplus[sum][pos] be an array that is the minimum number of pluses required to obtain the value 'sum' using the postfix starting at 'pos', then it's just simple recursion.
3) To avoid initialization, the array stores the number of pluses plus one.
3) To avoid initialization, the array stores the number of pluses plus one.
No comments:
Post a Comment