Leetcode 2288. Apply Discount to Prices
Tokenize the sentence by spaces and for each word that exactly matches a dollar sign followed by digits, compute price * (100 - discount) / 100 and replace it with a string formatted as "$" followed by exactly two decimal places; leave other words unchanged. Key points are correctly detecting valid price tokens (no extra characters), handling up to 10-digit prices and discounts 0–100, and precise two-decimal formatting.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.