Question
Implement allowlist-based input sanitization. Given a `value` string and an `allowlist` (a list of permitted characters), return a new string containing only the characters of `value` that appear in the allowlist, preserving their original order. Characters not on the allowlist are dropped entirely. This is the safe alternative to denylisting dangerous characters.
sanitize_input(value: str, allowlist: list[str]) → str["ab<script>12",["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"]]out"abscript12"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.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.