Skip to content

2806. Account Balance After Rounded Purchase 👍

  • Time: $O(1)$
  • Space: $O(1)$
1
2
3
4
5
6
class Solution {
 public:
  int accountBalanceAfterPurchase(int purchaseAmount) {
    return 100 - ((purchaseAmount + 5) / 10) * 10;
  }
};
1
2
3
4
5
class Solution {
  public int accountBalanceAfterPurchase(int purchaseAmount) {
    return 100 - ((purchaseAmount + 5) / 10) * 10;
  }
}
1
2
3
class Solution:
  def accountBalanceAfterPurchase(self, purchaseAmount: int) -> int:
    return 100 - ((purchaseAmount + 5) // 10) * 10