[AtCoder] B - Iroha Loves Strings (ABC Edition)Read more
[AtCoder] D - UnbalancedRead more
[AtCoder] C - Be TogetherRead more
[AtCoder] A - 2兆円Read more
[Codeforces] Round #603 (Div. 2) D. Secret PasswordsRead more
[AtCoder] Round #604 (Div. 1) A. Beautiful Regional ContestRead more
[Codeforces] Round #609 (Div. 2) B. Modulo EqualityRead more
[Codeforces] Round #605 (Div. 3) D. Remove One ElementRead more
[Codeforces] Educational Round 78 (Rated for Div. 2) B. A and BRead more
[LeetCode] Ternary Expression Parser

439. Ternary Expression Parser

Given a string expression representing arbitrarily nested ternary expressions, evaluate the expression, and return the result of it.

You can always assume that the given expression is valid and only contains digits, ‘?’, ‘:’, ‘T’, and ‘F’ where ‘T’ is true and ‘F’ is false. All the numbers in the expression are one-digit numbers (i.e., in the range [0, 9]).

The conditional expressions group right-to-left (as usual in most languages), and the result of the expression will always evaluate to either a digit, ‘T’ or ‘F’.

Read more