problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::minimum_cost_of_buying_candies_with_discount::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static int minimumCost (vector< int > &cost)
 

详细描述

在文件 leetcode.h589 行定义.

成员函数说明

◆ minimumCost()

int leetcode::minimum_cost_of_buying_candies_with_discount::Solution::minimumCost ( vector< int > &  cost)
static

在文件 leetcode.cpp1305 行定义.

1305 {
1306 if(cost.size() == 1) {
1307 return cost[0];
1308 }
1309 if(cost.size() == 2) {
1310 return cost[0] + cost[1];
1311 }
1312 int count = 0;
1313 sort(cost.rbegin(), cost.rend());
1314 for(int i = 0; i < cost.size(); i++) {
1315 if(i % 3 != 2) {
1316 count += cost[i];
1317 }
1318 }
1319 return count;
1320 }

被这些函数引用 leetcode::minimum_cost_of_buying_candies_with_discount::TEST().


该类的文档由以下文件生成: