Change Due
Easy · rating 800 · Math
A customer buys an item costing cost cents and pays with paid cents. Read the two space-separated integers cost and paid (with paid ≥ cost). Print the change to return, in cents.
Constraints: 0 ≤ cost ≤ paid ≤ 109
Editorial
Approach
Change owed is just what was paid minus what it cost. A single subtraction answers it.
cost, paid = map(int, input().split())
print(paid - cost)Complexity
Time: O(1). Space: O(1).
Related problems
- Absolute Value — Easy
- Even or Odd — Easy
- Multiply Two — Easy
- Sum of Two — Easy
- Array Sum — Easy
- Digital Root — Easy