Rod Cutting Problem, Longest Common Substring/Subsequence Problem