Ctrl K

Change After a Rounded Price

Easy
You have exactly 100 coins in your pocket. A kiosk that keeps no small change rounds every price to the nearest multiple of 10 and charges the rounded amount. A price that falls exactly halfway (say, 25) is rounded up (to 30). Zero counts as a multiple of 10 too. Given the price of a purchase price, return how many coins you have left after paying.
Example 1
price=37 → 60

The nearest round number to 37 is 40, so 100 − 40 = 60 is left.

Example 2
price=65 → 30

65 is exactly halfway between 60 and 70, so it rounds up to 70. 30 is left.

Example 3
price=4 → 100

4 is closer to 0 than to 10, so the purchase costs nothing and 100 is left.

Constraints
  • 0 ≤ price ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsA Number That Reads Both Ways EasyValue of a Roman Numeral EasyAdd One to a Digit Array EasySum of Binary Strings EasyWhole Square Root Easy
loading Python…
Input
price=37
Expected
60

Run checks the first 3 tests in your browser. Submit checks all 57 tests on the server, hidden ones included.