Environment Variable Store and Substitution
Problem statement
Process a sequence of environment-variable operations:
["SET", key, value]stores or overwrites a value.["GET", key]emits the value orNULLwhen missing.["PARSE", text]emitstextafter replacing every complete%KEY%placeholder whose key exists. Missing placeholders remain unchanged.
Substitution is one pass: replacement values are not expanded again during the same operation.
Function
processEnvironment(operations: String[][]) → String[]Examples
Example 1
operations = [["SET","NAME","Tom"],["PARSE","Hello I am %NAME%"]]return = ["Hello I am Tom"]The stored NAME value replaces its placeholder.
Example 2
operations = [["GET","MISSING"],["PARSE","%MISSING%"]]return = ["NULL","%MISSING%"]Missing GET and PARSE have distinct deterministic outputs.
Constraints
1 <= operations.length <= 10^5.- Keys contain letters, digits, or underscores and are nonempty.
- Each operation row has the required fields.