当前位置:网站首页>【leetcode周赛记录】第296场周赛记录
【leetcode周赛记录】第296场周赛记录
2022-06-09 12:08:00 【一二三o-0-O】
【leetcode周赛记录】第294场周赛记录
赛后个人排名
赛题分析总结
第296场周赛
2293.极大极小游戏
class Solution {
public:
int minMaxGame(vector<int>& nums) {
int n = nums.size();
vector<int> newVector = nums;
while(n > 1){
vector<int> tmp = newVector;
newVector.clear();
newVector.resize(n/2);
for(int i{
};i<n/2;i++){
if((i+1)%2 == 0){
newVector[i] = max(tmp[i*2],tmp[i*2+1]);
}else{
newVector[i] = min(tmp[i*2],tmp[i*2+1]);
}
}
n = n/2;
}
return newVector[0];
}
};
2294.划分数组使最大差为K
class Solution {
public:
// 贪心求解
int partitionArray(vector<int>& nums, int k) {
int n = nums.size();
sort(nums.begin(),nums.end());
int result{
};
int i{
};
while(i < n){
int j = i+1;
for(;j<n;++j){
if(nums[j]-nums[i] > k) break;
}
i = j;
result++;
}
return result;
}
};
2295.替换数组中的元素
class Solution {
public:
// hash计数求解
vector<int> arrayChange(vector<int>& nums, vector<vector<int>>& operations) {
int m = operations.size();
unordered_map<int,int> unMap;
for(int i{
};i<nums.size();++i){
unMap[nums[i]] = i;
}
for(int i{
};i<m;++i){
int m1 = operations[i][0];
int m2 = operations[i][1];
int index = unMap[m1];
nums[index] = m2;
unMap[m2] = index;
}
return nums;
}
};
2296.设计一个文本编辑器
第四题暂不考虑
反思总结
个人情况
第31次参加leetcode竞赛;
总计得到过5次12分,1次8分,15次7分,10次3分;
后续改进
- 贪心的专项复习、训练以及总结系统训练,总结
边栏推荐
猜你喜欢
随机推荐
Image matrix transformation in gdi+
[STM32] Hal library DAC
【代码学习】批量提取论文(pdf)的第一页
[简化] [排除]
保姆级教程:如何成为Apache Linkis文档贡献者
Core implementation of Kube apiserver scheduler
MYSQL学习笔记
【Prometheus summary.observe 方法】
Golang-RPC(七):如何调试gRPC服务
Golang接入钉钉通知
【 Loki简介,部署,使用 】
[Thesis Writing] AI conference citation format, publishing place and publishing house
Make qcombobox drop down a tree structure list
How to do the third question of multi table query in MySQL database?
GDI+ 中区域的使用
Connaissance de base de l'analyse modale que l'Ingénieur devrait connaître
NVIDIA 发布最新版本的TAO工具包,进一步简化和加速AI模型创建
Golang access pin notification
炒作剽窃、内鬼欺诈 OpenSea上常见的NFT骗局及安全建议
View Thread name and set thread name








