当前位置:网站首页>6090. 极大极小游戏
6090. 极大极小游戏
2022-07-02 12:10:00 【紫菜(Nori)】
class Solution {
public:
int minMaxGame(vector<int>& nums) {
int i = 0;
int len = nums.size();
while(len != 1){
// i可到达的位置
int availableLen = len >> 1;
while(i < availableLen){
int ind = (i << 1);
if(1 == (i & 0x01)){
// 奇数
nums[i] = max(nums[ind], nums[ind + 1]);
}else{
// 偶数
nums[i] = min(nums[ind], nums[ind + 1]);
}
i++;
}
// 开始下一次访问
i = 0;
// 对半
len >>= 1;
}
return nums[0];
}
};边栏推荐
猜你喜欢

I made an istio workshop. This is the first introduction

PTA 天梯赛习题集 L2-001 城市间紧急救援

6.12 企业内部upp平台(Unified Process Platform)的关键一刻

18_ Redis_ Redis master-slave replication & cluster building

【LeetCode】1254-统计封闭岛屿的数量

Solution of Queen n problem

损失函数与正负样本分配:YOLO系列

Evaluation of embedded rz/g2l processor core board and development board of Feiling

Basic knowledge of cryptography

终于搞懂了JS中的事件循环,同步/异步,微任务/宏任务,运行机制(附笔试题)
随机推荐
工程师评测 | RK3568开发板上手测试
【LeetCode】695-岛屿的最大面积
17_ Redis_ Redis publish subscription
Be a good gatekeeper on the road of anti epidemic -- infrared thermal imaging temperature detection system based on rk3568
6095. 强密码检验器 II
yolo格式数据集处理(xml转txt)
13_Redis_事务
10_ Redis_ geospatial_ command
04. Some thoughts on enterprise application construction after entering cloud native
飞凌嵌入式RZ/G2L处理器核心板及开发板上手评测
【LeetCode】977-有序數組的平方
Data analysis thinking analysis methods and business knowledge - business indicators
FPGA - 7系列 FPGA内部结构之Clocking -03- 时钟管理模块(CMT)
Equipped with Ti am62x processor, Feiling fet6254-c core board is launched!
Real estate market trend outlook in 2022
Libcurl Lesson 13 static library introduces OpenSSL compilation dependency
微信支付宝账户体系和支付接口业务流程
LeetCode刷题——递增的三元子序列#334#Medium
Bing. Com website
[leetcode] 1905 statistics sub Island