Tap here to switch tabs
Problem
Submissions

Problem: Ternary Expression Parser

med
30 min
Try to solve the Ternary Expression Parser problem.

Statement

Given a string expression representing a nested ternary expression, evaluate the expression and return its result as a string.

You can assume that the ternary expression evaluates from right to left.

Constraints:

  • 5≤5 \leq expression.length ≤104\leq 10^4

  • expression consists of digits, 'T', 'F', '?', and ':'.

  • It is guaranteed that expression is a valid ternary expression and that each number is a single digit number.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Ternary Expression Parser

med
30 min
Try to solve the Ternary Expression Parser problem.

Statement

Given a string expression representing a nested ternary expression, evaluate the expression and return its result as a string.

You can assume that the ternary expression evaluates from right to left.

Constraints:

  • 5≤5 \leq expression.length ≤104\leq 10^4

  • expression consists of digits, 'T', 'F', '?', and ':'.

  • It is guaranteed that expression is a valid ternary expression and that each number is a single digit number.