Implement prototype(values, blocked) and solve(values, blocked). Both return a new array of surviving Number values in original order, excluding every value present in the blocked array. [1, 2, 3, 2, 4] blocked by [1, 2] returns [3, 4]. Empty arrays are valid. Preserve both arrays.

Also implement detach(head, blocked) using the supplied Node class; head is Node or null and blocked is a Set of Numbers. Relink existing nodes only. Every surviving object must retain its identity and order, and the result must be acyclic and end at null. Null input or complete removal returns null. A temporary sentinel is allowed; do not mutate blocked. Identity checks run in both stages.

Prototype: filter values into a new array. Final: complete the linked-list operation as well as the values API. Link mutation is allowed inside detach; replacement survivor allocations are not.

All numeric inputs and finite arithmetic results in this lesson are safe-integer Numbers. Use null for documented absence, not undefined or a numeric sentinel. Return actual booleans where the contract requires them. Do not add validation requirements beyond the documented inputs.

Run with Node.js 20+ from this directory:

Shell
node main.mjs --stage prototype
node main.mjs --stage final

Edit exercise.mjs; keep main.mjs unchanged. Both stages begin as unfinished learner functions. The website uses the same test functions in a separate browser worker. Tests check deterministic examples, boundaries, documented validation, input preservation, and stage-specific cases. Passing tests does not prove the required time complexity.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.