当前位置:网站首页>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];
}
};
边栏推荐
- Solve the problem of frequent interruption of mobaxterm remote connection
- 20_ Redis_ Sentinel mode
- 14_ Redis_ Optimistic lock
- Storage read-write speed and network measurement based on rz/g2l | ok-g2ld-c development board
- [leetcode] 977 square of ordered array
- Oracle primary key auto increment
- Bing.com網站
- Real estate market trend outlook in 2022
- Bing. Site Internet
- 百变大7座,五菱佳辰产品力出众,人性化大空间,关键价格真香
猜你喜欢
Leetcode skimming -- sum of two integers 371 medium
Yolo format data set processing (XML to txt)
【LeetCode】1905-统计子岛屿
搭载TI AM62x处理器,飞凌FET6254-C核心板首发上市!
LeetCode刷题——两整数之和#371#Medium
Engineer evaluation | rk3568 development board hands-on test
6.12 critical moment of Unified Process Platform
Solve the problem of frequent interruption of mobaxterm remote connection
07_ Hash
Markdown tutorial
随机推荐
[leetcode] 877 stone game
FPGA - 7系列 FPGA内部结构之Clocking -03- 时钟管理模块(CMT)
18_ Redis_ Redis master-slave replication & cluster building
【LeetCode】189-轮转数组
Yolov5 code reproduction and server operation
Case introduction and problem analysis of microservice
搭载TI AM62x处理器,飞凌FET6254-C核心板首发上市!
Let your HMI have more advantages. Fet-g2ld-c core board is a good choice
LeetCode_ String_ Simple_ 412.Fizz Buzz
13_Redis_事务
How to intercept the value of a key from the JSON string returned by wechat?
[leetcode] 200 number of islands
[leetcode] 1162 map analysis
Semantic segmentation learning notes (1)
[development environment] install the Chinese language pack for the 2013 version of visual studio community (install test agents 2013 | install visual studio 2013 simplified Chinese)
Loss function and positive and negative sample allocation: Yolo series
MySQL -- Index Optimization -- order by
【LeetCode】283-移动零
Bing. Com website
XML Configuration File