Postfix With Max and Min
tokens is a postfix (reverse Polish) expression. Each token is either an integer written as a string, possibly negative like "-3", or one of the operators +, -, *, max and min.
An operator uses the two most recent values, the earlier one on the left: for - the result is left - right, and max and min give the larger and the smaller of the two. The expression is always valid and leaves exactly one value. Return that value.
Example 1
tokens ["3","4","max","2","*"]
returns 8
3 4 max is 4, then 4 2 * is 8.
Example 2
tokens ["5","1","2","+","-"]
returns 2
1 2 + is 3, then 5 3 - is 2.
Constraints
1 <= len(tokens) <= 41- every number token is between
-100and100 - every intermediate result is between
-1000000and1000000
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.