Leetcode Weekly 419
A
C++
https://telegram.me/+_hn3cBQVbGliYTI9
#include
#include
#include
using namespace std;
class Solution {
public:
vector findXSum(vector& nums, int k, int x) {
int n = nums.size();
vector answer;
for (int i = 0; i b.first;
return a.second > b.second;
});
int sum = 0;
int count = 0;
for (const auto& entry : freqList) {
int frequency = entry.first;
int value = entry.second;
if (count >= x) break;
sum += frequency * value;
count++;
}
answer.push_back(sum);
}
return answer;
}
};
Leetcode Weekly 419
A
C++
https://telegram.me/+_hn3cBQVbGliYTI9
A
C++
https://telegram.me/+_hn3cBQVbGliYTI9
#include
#include
#include
using namespace std;
class Solution {
public:
vector findXSum(vector& nums, int k, int x) {
int n = nums.size();
vector answer;
for (int i = 0; i b.first;
return a.second > b.second;
});
int sum = 0;
int count = 0;
for (const auto& entry : freqList) {
int frequency = entry.first;
int value = entry.second;
if (count >= x) break;
sum += frequency * value;
count++;
}
answer.push_back(sum);
}
return answer;
}
};
Leetcode Weekly 419
A
C++
https://telegram.me/+_hn3cBQVbGliYTI9