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

#include <leetcode.h>

静态 Public 成员函数

static int maximumProduct (vector< int > &nums, int k)
 

详细描述

在文件 leetcode.h2175 行定义.

成员函数说明

◆ maximumProduct()

int leetcode::maximum_product_after_k_increments::Solution::maximumProduct ( vector< int > &  nums,
int  k 
)
static

在文件 leetcode.cpp5845 行定义.

5845 {
5846 priority_queue<int, vector<int>, greater<int>> pq;
5847 for(auto num: nums) {
5848 pq.push(num);
5849 }
5850 while(k-- != 0) {
5851 const int num = pq.top();
5852 pq.pop();
5853 pq.push(num + 1);
5854 }
5855 long long ans = 1;
5856 while(!pq.empty()) {
5857 const int num = pq.top();
5858 pq.pop();
5859 ans *= num;
5860 ans %= 1000000007;
5861 }
5862 return ans;
5863 }

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


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