Refactored the dynamic programming version of longestCommonSubstring to be functional.