当前位置:网站首页>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];
}
};
边栏推荐
猜你喜欢
Leetcode skimming -- verifying the preorder serialization of binary tree # 331 # medium
Leetcode skimming -- sum of two integers 371 medium
基于RZ/G2L | OK-G2LD-C开发板存储读写速度与网络实测
Pytorch 保存tensor到.mat文件
yolo格式数据集处理(xml转txt)
Leetcode skimming -- count the number of numbers with different numbers 357 medium
Loss function and positive and negative sample allocation: Yolo series
FPGA - 7系列 FPGA内部结构之Clocking -03- 时钟管理模块(CMT)
18_ Redis_ Redis master-slave replication & cluster building
Guangzhou Emergency Management Bureau issued a high temperature and high humidity chemical safety reminder in July
随机推荐
Pytorch 保存tensor到.mat文件
03. Preliminary use of golang
19_ Redis_ Manually configure the host after downtime
Build your own semantic segmentation platform deeplabv3+
6.12 企业内部upp平台(Unified Process Platform)的关键一刻
04.进入云原生后的企业级应用构建的一些思考
Loss function and positive and negative sample allocation: Yolo series
Leetcode question brushing - parity linked list 328 medium
yolo格式数据集处理(xml转txt)
【LeetCode】876-链表的中间结点
Real estate market trend outlook in 2022
6092. 替换数组中的元素
QML pop-up frame, customizable
搭载TI AM62x处理器,飞凌FET6254-C核心板首发上市!
The traversal methods of binary tree mainly include: first order traversal, middle order traversal, second order traversal, and hierarchical traversal. First order, middle order, and second order actu
士官类学校名录
微信支付宝账户体系和支付接口业务流程
Bing.com網站
Solution of Queen n problem
11_ Redis_ Hyperloglog_ command