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" दिखाते हैं, तो चैलेंज इस ब्राउज़र में हल के रूप में चिह्नित हो जाता है।
अपना समाधान समीक्षा के लिए भेजें