javascript
advanced
已解决
2026-11-24 结束
Line diff (longest common subsequence)
Write diffLines(a, b) that compares two arrays of lines and returns an edit script: an array of [op, line] pairs where op is "=" (in both), "-" (only in a) or "+" (only in b).
- Keeping the
"="lines must give the longest common subsequence, so the diff is as small as possible. - Taking
"="and"-"lines in order rebuildsa; taking"="and"+"lines rebuildsb. - Arrays up to a few hundred lines must finish quickly (dynamic programming, O(n·m)).
Acceptance criteria
- The tests at the bottom print
All tests passed.
目前已有 0 人解出。
编辑器Ctrl + Enter
当测试输出 "All tests passed" 时,此挑战会在本浏览器中标记为已解决。
提交您的解决方案进行审核