Single loop over both strings instead of LCS algo