LeetCode --- 2144. Minimum Cost of Buying Candies With Discount 解题报告

Question:

A shop is selling candies at a discount. For every two candies sold, the shop gives a third candy for free.

The customer can choose any candy to take away for free as long as the cost of the chosen candy is less than or equal to the minimum cost of the two candies bought.

  • For example, if there are 4 candies with costs 123, and 4, and the customer buys candies with costs 2 and 3, they can take the candy with cost 1 for free, but not the candy with cost 4.

Given a 0-indexed integer array cost, where cost[i] denotes the cost of the ith candy, return the minimum cost of buying all the candies.

Example 1:

相关推荐

  1. LeetCode 1378、1277、2944

    2024-07-18 06:02:06       48 阅读
  2. LeetCode --- 2103. Rings and Rods 解题报告

    2024-07-18 06:02:06       17 阅读
  3. LeetCode --- 2129. Capitalize the Title 解题报告

    2024-07-18 06:02:06       20 阅读
  4. Leetcode2744. 最大字符串配对数目

    2024-07-18 06:02:06       54 阅读
  5. leetcode2744. 最大字符串配对数目

    2024-07-18 06:02:06       51 阅读
  6. LeetCode2744】最大字符串配对数目

    2024-07-18 06:02:06       56 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-18 06:02:06       70 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-18 06:02:06       74 阅读
  3. 在Django里面运行非项目文件

    2024-07-18 06:02:06       62 阅读
  4. Python语言-面向对象

    2024-07-18 06:02:06       72 阅读

热门阅读

  1. PHP + Swoole 与 Go 技术选型对比调研报告

    2024-07-18 06:02:06       18 阅读
  2. Spring Boot 注解 @PostConstruct 介绍

    2024-07-18 06:02:06       24 阅读
  3. 从零手写实现 nginx-31-load balance 负载均衡介绍

    2024-07-18 06:02:06       26 阅读
  4. Elasticsearch数据迁移

    2024-07-18 06:02:06       18 阅读
  5. 构建管理大师:如何在Gradle中配置源代码目录

    2024-07-18 06:02:06       21 阅读
  6. 深入解析:如何在Gradle中配置签名插件

    2024-07-18 06:02:06       23 阅读
  7. LeetCode 算法:括号生成 c++

    2024-07-18 06:02:06       22 阅读
  8. Apache Omid TSO 组件源码实现原理

    2024-07-18 06:02:06       22 阅读
  9. php 方法追踪其被调用的踪迹

    2024-07-18 06:02:06       20 阅读
  10. 山东航空小程序查询

    2024-07-18 06:02:06       25 阅读
  11. 怎么查看占用端口的 PID

    2024-07-18 06:02:06       20 阅读
  12. 算法1.快速幂【a^b、(a^b)%p】

    2024-07-18 06:02:06       23 阅读
  13. 第三节SHELL脚本中的变量与运算(2.2)

    2024-07-18 06:02:06       20 阅读
  14. nng协议nni_posix_resolv_sysinit()系统初始化

    2024-07-18 06:02:06       23 阅读
  15. Tensor列表索引本质

    2024-07-18 06:02:06       21 阅读