use DP in longestCommonSubstring

Used the dynamic programming approach to reduce the complexity of longestCommonSubstring to O(mn) from O(mn^2).
You can create an empty map with `Map.empty[(Int, Int), Int]`.