Verily OA Interview Problem: Function Name Normalization

50 Views
No Comments

{'x': '%y%', 'y': '%z%_abc', 'z': 'abc'}

Given the mapping above, evaluate function('x') and return the final output.

function('x') -> output: abc_abc

This problem asks you to recursively expand a string mapping until every reference is resolved. A typical solution uses DFS or recursion with memoization to avoid repeated work when names depend on one another. The key challenge is handling nested substitutions in the correct order and producing the final concatenated string.

END
 0