You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: solution/2800-2899/2806.Account Balance After Rounded Purchase/README_EN.md
+39-17
Original file line number
Diff line number
Diff line change
@@ -18,35 +18,57 @@ tags:
18
18
19
19
<!-- description:start -->
20
20
21
-
<p>Initially, you have a bank account balance of <code>100</code> dollars.</p>
21
+
<p>Initially, you have a bank account balance of <strong>100</strong> dollars.</p>
22
22
23
-
<p>You are given an integer <code>purchaseAmount</code> representing the amount you will spend on a purchase in dollars.</p>
23
+
<p>You are given an integer <code>purchaseAmount</code> representing the amount you will spend on a purchase in dollars, in other words, its price.</p>
24
24
25
-
<p>At the store where you will make the purchase, the purchase amount is rounded to the <strong>nearest multiple</strong> of <code>10</code>. In other words, you pay a <strong>non-negative</strong> amount, <code>roundedAmount</code>, such that <code>roundedAmount</code> is a multiple of <code>10</code> and <code>abs(roundedAmount - purchaseAmount)</code> is <strong>minimized</strong>.</p>
25
+
<p>When making the purchase, first the <code>purchaseAmount</code> <strong>is rounded to the nearest multiple of 10</strong>. Let us call this value <code>roundedAmount</code>. Then, <code>roundedAmount</code> dollars are removed from your bank account.</p>
26
26
27
-
<p>If there is more than one nearest multiple of <code>10</code>, the <strong>largest multiple</strong> is chosen.</p>
27
+
<p>Return an integer denoting your final bank account balance after this purchase.</p>
28
28
29
-
<p>Return <em>an integer denoting your account balance after making a purchase worth </em><code>purchaseAmount</code><em> dollars from the store.</em></p>
29
+
<p><strong>Notes:</strong></p>
30
30
31
-
<p><strong>Note:</strong> <code>0</code> is considered to be a multiple of <code>10</code> in this problem.</p>
31
+
<ul>
32
+
<li>0 is considered to be a multiple of 10 in this problem.</li>
33
+
<li>When rounding, 5 is rounded upward (5 is rounded to 10, 15 is rounded to 20, 25 to 30, and so on).</li>
34
+
</ul>
32
35
33
36
<p> </p>
34
37
<p><strongclass="example">Example 1:</strong></p>
35
38
36
-
<pre>
37
-
<strong>Input:</strong> purchaseAmount = 9
38
-
<strong>Output:</strong> 90
39
-
<strong>Explanation:</strong> In this example, the nearest multiple of 10 to 9 is 10. Hence, your account balance becomes 100 - 10 = 90.
0 commit comments