Back to Browse

Final Prices With a Special Discount in a Shop - Leetcode 1475 - Java

217 views
Dec 18, 2024
8:26

🧩 *PROBLEM DESCRIPTION* You are given an integer array `prices` where `prices[i]` is the price of the `ith` item in a shop. There is a special discount for items in the shop. If you buy the `ith` item, then you will receive a discount equivalent to `prices[j]` where `j` is the minimum index such that `j > i` and `prices[j] <= prices[i]`. Otherwise, you will not receive any discount at all. Return an integer array `answer` where `answer[i]` is the final price you will pay for the `ith` item of the shop, considering the special discount. ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ 🔗 *LINKS* ⭐Problem: https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop/ 💻Code: https://k5kc.com/cs/problems/final-prices-with-a-special-discount-in-a-shop/ ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ 📂 *RELATED PLAYLISTS To Explore* 📃 Array Datastructure: https://www.youtube.com/playlist?list=PLB53ggSrd6qkSyvwZxLym8mYgjgGFVcs8 📚 Monotonic Stack: https://www.youtube.com/playlist?list=PLB53ggSrd6qnuGLPH6i1QwpBWyZZ7vr-0 📚 Stack Data Structure: https://www.youtube.com/playlist?list=PLB53ggSrd6qkVc2unL_xP1iVUC2I1hZyT 🟢 Easy Coding Problems: https://www.youtube.com/playlist?list=PLB53ggSrd6qlIa5z85qXrwS2J0s8xBY0u ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ 🔔 _SUPPORT AND SUBSCRIBE_ Don’t forget to **like**, **subscribe**, and **comment** for more problem-solving content! 🚀 🎯 _Follow me for updates_: GitHub: https://github.com/kinshuk4 Twitter: https://x.com/k5kc_ Instagram: https://www.instagram.com/_k5kc_/ LinkedIn: https://www.linkedin.com/company/k5kc/

Download

0 formats

No download links available.

Final Prices With a Special Discount in a Shop - Leetcode 1475 - Java | NatokHD