Evaluate Simple Expression

Python Medium 2 views
Back to Questions

Problem Description

Read n assignments like name value (integer). Then one expression is provided as: name1 op name2 where op is + or -. Output result using stored values. Missing names are treated as 0.

Input Format

First line n. Next n lines: name value. Last line: name1 op name2.

Output Format

One integer result.

Sample Test Case

Input:
3 a 10 b 4 c 2 a - b
Output:
6

Constraints

n

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next