Redact sensitive nested values
Redact sensitive values from a nested structure before logging. Given a JSON-like structure (dicts, lists, and scalars) and a list of sensitive key names (case-insensitive), return a deep copy where any dict value whose key matches a sensitive name (compared lowercased) is replaced with the string '[REDACTED]', recursing into nested dicts and lists. Non-matching scalars are left as-is. Do not mutate the input.
Implement
redact(data: any, sensitive: list[str]) → anyExamples
in
[{"user":"alice","password":"p@ss"},["password"]]out{"user":"alice","password":"[REDACTED]"}What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 25 min
solution.py
InputExpectedGot
[{"user":"alice","password":"p@ss"},["password"]]{"user":"alice","password":"[REDACTED]"}not run yetsample