Back to problems

Add/Sub Calculator with String Verification Follow-up

Algorithm · Uber · Medium

Problem: Validate and Evaluate an Add/Sub Expression You receive a string s that encodes an arithmetic expression. Its permitted contents are limited to: Numerals from 0 through 9 The addition symbol + The subtraction symbol - Optional space characters ' ' Complete the following two tasks: Expression validation: check whether s forms a valid expression. When the expression is valid, compute and print its value; when it is not, print INVALID. What counts as a valid expression…

Checking your access…