Sign In
You are coding as a Guest. Sign in with your RoleNest account to permanently track your streak, earn XP, and climb the Campus Leaderboard!
Sign In with RoleNest
🔥Structured Deep Clone (State Immutability)Medium
MediumWeb Engineering•Acceptance: 59.3%

Structured Deep Clone (State Immutability)

Real-World Engineering Context
Essential for predictable React Redux/Zustand state immutability, undo-redo histories, and form drafts.
Given a JSON-compatible nested dictionary/object `obj`, implement a deep clone that produces an independent copy. Mutating the clone must never affect the original.

Sample Test Cases

Input: [{"a":1,"b":[2,3]}]
Expected: {"a":1,"b":[2,3]}
Input: [{"user":{"name":"Alex","roles":["admin"]}}]
Expected: {"user":{"name":"Alex","roles":["admin"]}}

Constraints

  • Object contains only primitive types, lists, and dicts.