Skip to interview prep
Apexed

2. Fix the leaking shared state

EasyDebugging & productionDebugging

addTag should return a new list containing the given tags plus the new tag, without changing its input. Each call is independent, but results leak between calls.

Example 1

Input: addTag('a'); addTag('b')
Output: ['b'] for the second call

Constraints

  • Fix the bug; keep the function signature

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 4 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Fix the leaking shared state — coding interview practice — Apexed