# [Leetcode] Training day-007

1475. Final Prices With a Special Discount in a Shop

Given the 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 array where the `ith` element is the final price you will pay for the `ith` item of the shop considering the special discount.

Constraints:

• `1 <= prices.length <= 500`
• `1 <= prices[i] <= 10^3`

1642. Furthest Building You Can Reach

You are given an integer array `heights` representing the heights of buildings, some `bricks`, and some `ladders`.

You start your journey from building `0` and move to the next building by possibly using bricks or ladders.

While moving from building `i` to building `i+1` (0-indexed),

• If the current building’s height is greater than or equal to the next building’s height, you do not need a ladder or bricks.
• If the current building’s height is less than the next building’s height, you can either use one ladder or `(h[i+1] - h[i])` bricks.

Return the furthest building index (0-indexed) you can reach if you use the given ladders and bricks optimally.

Constraints:

• `1 <= heights.length <= 105`
• `1 <= heights[i] <= 106`
• `0 <= bricks <= 109`
• `0 <= ladders <= heights.length`

--

--