An audit log records which settings changed, as dotted paths like editor.font.size or plugins.2.
Write changedPaths(before, after) for two JSON objects. Compare them recursively: when both values at a path are plain objects, compare each key in either one; when both are arrays, compare each index up to the longer length. A key or index that exists on only one side is reported at that path. Any other pair of values (including an object against an array) is reported if the two aren't deep-equal. Paths join keys and indexes with ..
Return the paths sorted in character-code order, as sort() sorts strings.
Input: before = {"theme":"dark","editor":{"font":{"size":14,"family":"mono"},"tabs":2}}, after = {"theme":"dark","editor":{"font":{"size":16,"family":"mono"},"wrap":true}} Output: ["editor.font.size","editor.tabs","editor.wrap"]
size changed, tabs was removed, and wrap was added.
Input: before = {"plugins":["a","b"]}, after = {"plugins":["a","c","d"]} Output: ["plugins.1","plugins.2"]
Index 1 changed and index 2 is new.
10^4 values in total...Run 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 #740 List Changed Setting Paths. 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.