Amazon | Onsite | Reduced Price in a String (Reject)
Anonymous User
1155

I got the following question in one of the rounds in Onsite Interview. Looking for different approaches you will take to solve this problem or if anyone has seen this question before?

Problem Statement:

Write a function to take a string and decrease all costs in the string by 15%. Currencies can be of the form 5.25 and USD 5.25. Solution must work for these currency format but keep in mind we want to extend the solution to work for international currencies as well. For e.g. EUR, GBP etc.

You are given a string containing product information and it's price. 
Write a function which returns the same sentence but with a reduced price.
Example:
I/P: "Two Litre Coca-Cola costs $2.99".
O/P: "Two Litre Coca-Cola costs $2.54".
Comments (7)