假設我有一個大字符串和一個子字符串數組,當它們與大字符串相等時(差別很小)。 例如(注意字符串之間的細微差別): large_str = "hello, this is a long string, that may be made up of multiple
substrings that approximately match the original string"
sub_strs
我想在榆樹中製作一個高效版本的LCS算法。 我喜歡這個ocaml版本,但它使用副作用來緩存結果。 let lcs xs ys =
let cache = Hashtbl.create 16 in
let rec lcs xs ys =
try Hashtbl.find cache (xs, ys) with
| Not_found ->
let
我們的教授給了我們以下問題: Input
A sequence of characters X = x1, x2, ... ,xn
Output
The length of the longest sub-sequence of X that is a palindrome
我的解決辦法是: Take X and reverse it into the sequence