You are given a list of substitution rules replacements and a string text.
Each rule in replacements is a pair [key, value], indicating that any placeholder in the format "%<key>%" should be replaced with its corresponding value. A value may itself contain zero or more placeholders referencing other keys.
Return the final string after fully substituting all placeholders in text and in any nested value strings until no placeholders remain.
Constraints:
replacements.length
Each element of replacements is a list of [key, value].
key is a single uppercase English letter.
value.length
value consists of characters and optional placeholders formatted as "%<key>%".
All key values in replacements are unique.
text is formed by concatenating all key placeholders from replacements in some order, separated by underscores (_).
text.length replacements.length
Every placeholder in text or in any value corresponds to a valid key in replacements.
There are no cyclic dependencies among replacement keys.
You are given a list of substitution rules replacements and a string text.
Each rule in replacements is a pair [key, value], indicating that any placeholder in the format "%<key>%" should be replaced with its corresponding value. A value may itself contain zero or more placeholders referencing other keys.
Return the final string after fully substituting all placeholders in text and in any nested value strings until no placeholders remain.
Constraints:
replacements.length
Each element of replacements is a list of [key, value].
key is a single uppercase English letter.
value.length
value consists of characters and optional placeholders formatted as "%<key>%".
All key values in replacements are unique.
text is formed by concatenating all key placeholders from replacements in some order, separated by underscores (_).
text.length replacements.length
Every placeholder in text or in any value corresponds to a valid key in replacements.
There are no cyclic dependencies among replacement keys.