Evaluate an Expression Map
You are given symbol definitions in the form name=expression. An expression may contain integer constants, references to previously defined or later defined symbols, and the binary operators +, -, *, and /.
Evaluate the final integer value of every symbol. Return the results in the same order as the input definitions, formatted as "name=value".
If the dependency graph contains a cycle, return a single-element array ["CYCLE"] instead of partial results.
Complete the function evaluateExpressionMap in the editor below.
evaluateExpressionMap has the following parameter:
String[] definitions: the symbol definitions
Returns
String[]: evaluated symbol assignments in input order, or ["CYCLE"] if a cycle exists.
1Example 1
Each symbol depends only on earlier evaluated values, so the map resolves cleanly.
2Example 2
The definitions form a cycle, so the special cycle marker is returned.
Constraints
Limits and guarantees your solution can rely on.
1 <= definitions.length <= 10^5- Expressions use integer arithmetic and may reference other symbols.
- Use cycle detection to avoid infinite recursion.