30 Days of Code [Day 18]
QUESTION : 1475. Final Prices With a Special Discount in a Shop
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define fo(i,s,n) for(int i=s;i<n;++i)
#define of(i,s,n) for(int i=s-1;i>=n;--i)
#define fv(V) for( auto &it : V )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
class Solution {
public:
vector<int> finalPrices(vector<int>& prices) {
fastio;
fo(i,0,prices.size()){
fo(j,i+1,prices.size()){
if(prices[j] <= prices[i]){
prices[i] -= prices[j];
break;
}
}
}
return prices;
}
};