This is a verified interview question from Flipkart-grid-8.0. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Megastore Partitioning - Flipkart Grid 8.0" covers key patterns like Other.
"The megastore has kept an offer saying that, if the customer can identify a product whose price is a golden price G, then it is absolutely free for them. A golden price is defined as a number G, whose difference between the sum of the digits and the highest digit is equal to the highest digit.  For example: - 352 → (3+5+2) − 5 = 5 ✓ - 3003 → (3+0+0+3) − 3 = 3 ✓ - 32872 → (3+2+8+7+2) − 8 = 8 ✓ *(as printed on screen)* Narendra goes to the megamarket and buys one unit of a product in the price range of (X, Y). Now he wants to know the amount he saved by selecting the golden price product from the list. As you are a friend of Narendra, can you help him calculate the total amount he saved by purchasing one product in the price range of X and Y. Read the input from STDIN and write the output to STDOUT. You should not write arbitrary strings while reading the input and while printing, as these contribute to the standard output. **Constraints:** 1 < X, Y < 100000 **Input Format:** Single line of input contains the price ranges X and Y. **Output Format:** A single line of output is the total amount that he saved. **Sample Input 1:** ``` 10 100 ``` **Sample Output 1:** ``` 495 ``` **Explanation 1:** Given the price range X and Y is 10 and 100. After checking all the golden prices of items between 10 and 100 we get 11, 22, 33, 44, 55, 66, 77, 88, 99. So after adding 11 + 22 + 33 + ... + 99 = 495. **Sample Input 2:** ``` 10 1000 ``` **Sample Output 2:** ``` 63270 ``` **Explanation 2:** After checking all the golden prices of items between 10 and 1000, we get 11, 22, 33, ..., 99, 101, 110, 112, ..., 880, 891, 909, 918, 927, 936, 945, 954, 963, 972, 981, 990. Adding them all gives 63270."
Join thousands of developers practicing for Flipkart-grid-8.0.