A code review page shows a badge like +3 -2 for each file. It counts lines as a diff tool would: it keeps as many lines unchanged as possible, in order, and every other line is a deletion from the old version or an insertion in the new one.
Write changedLines(oldLines, newLines) that returns the total number of deleted plus inserted lines in such a smallest diff.
Input: oldLines = ["title","intro","body"], newLines = ["title","body","footer"] Output: 2
Keep title and body; delete intro and insert footer.
Input: oldLines = ["a","b"], newLines = ["a","b"] Output: 0
Nothing changed.
0 <= oldLines.length, newLines.length <= 1000Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #713 Count Changed Lines. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.