concept strawberry jam in category algorithms
appears as: strawberry jam

This is an excerpt from Manning's book Algorithms and Data Structures in Action.
So, what would have looked like the most natural approach, a greedy[6] algorithm that at each step chooses the best immediate option, does not work. This problem needs to be carefully thought through.