2144. Minimum Cost of Buying Candies With Discount || In JAVA || Leetcode Problem || Easy #leetcode

preview_player
Показать описание
Hello Friends,
here I have discussed a leetcode problem. I solved this in JAVA.
I hope this video will help you.:)
Feel free to ask if you have any questions and you can give me any suggestions that I can improve!

Thanks for watching!

Leetcode Problems:
Рекомендации по теме
Комментарии
Автор

Code:-

class Solution {
public int minimumCost(int[] cost) {

Arrays.sort(cost);
int count = 0;
int pay=0;

for(int i = cost.length-1;i>=0;i--){

count++;
if(!(count%3 == 0))
{
pay=pay+cost[i];

}
}

return pay;

}
}

quicklearninigwithsree
join shbcf.ru