Adapt find_candidates into an lcs() function