2806. Account Balance After Rounded Purchase
Initially, you have a bank account balance of
100dollars.You are given an integer
purchaseAmountrepresenting the amount you will spend on a purchase in dollars.At the store where you will make the purchase, the purchase amount is rounded to the nearest multiple of
10. In other words, you pay a non-negative amount,roundedAmount, such thatroundedAmountis a multiple of10andabs(roundedAmount - purchaseAmount)is minimized.If there is more than one nearest multiple of
10, the largest multiple is chosen.Return an integer denoting your account balance after making a purchase worth
purchaseAmountdollars from the store.Note:
0is considered to be a multiple of10in this problem.
1 | class Solution { |