Code RoomString literal tokenizer
HardPrep Room Coding #807

String literal tokenizer

CodingAlgorithms & data structuresSenior–Staff~35 min

Tokenize a string that may contain double-quoted string literals and bare words separated by spaces. A string literal starts and ends with a double quote and supports backslash escapes inside: '\n' -> newline, '\t' -> tab, '\"' -> a literal double quote, '\\' -> a literal backslash; any other escape '\x' yields the character x literally. Bare words are maximal runs of non-space, non-quote characters. Spaces outside quotes separate tokens and are discarded. Return a list of the decoded token strings in order (quotes themselves are not part of the value). Assume every opened quote is closed. Empty or all-space input returns an empty list.

Implement
lex_strings(src: str) → list
Examples
in["hello \"a b\" world"]out["hello","a b","world"]
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 35 min
InputExpectedGot
["hello \"a b\" world"]["hello","a b","world"]not run yetsample