当前位置:网站首页>Force buckle ----- remove the maximum and minimum values from the array
Force buckle ----- remove the maximum and minimum values from the array
2022-06-26 09:44:00 【qq_ thirty-seven million seven hundred and sixty thousand seven】

int minimumDeletions(int* nums, int numsSize){
if(numsSize==1){
return 1;
}
int min=100000;
int max=-100000;
int min_index;
int max_index;
for(int a=0;a<numsSize;a++){
if(nums[a]<min){
min=nums[a];
min_index=a;
}
if(nums[a]>max){
max=nums[a];
max_index=a;
}
}
int left=min_index>max_index?min_index+1:max_index+1;
int right=max_index<min_index?numsSize-max_index:numsSize-min_index;
int record=left<right?left:right;
if(max_index<numsSize-1-max_index&&min_index>numsSize-1-min_index){
return record<max_index+1+numsSize-min_index?record:max_index+1+numsSize-min_index;
}
else if(max_index<numsSize-1-max_index&&min_index<numsSize-1-min_index){
return record<(max_index>min_index?max_index+1:min_index+1)?record:max_index>min_index?max_index+1:min_index+1;
}
else if(max_index>numsSize-1-max_index&&min_index<numsSize-1-min_index){
return record<min_index+1+numsSize-max_index?record:min_index+1+numsSize-max_index;
}
else if(max_index>numsSize-1-max_index&&min_index>numsSize-1-min_index){
return record<numsSize-(max_index<min_index?max_index:min_index)?record:numsSize-(max_index<min_index?max_index:min_index);
}
else if(max_index==numsSize-1-max_index){
return record<max_index+1?record:max_index+1;
}
else if(min_index==numsSize-1-min_index){
return record<min_index+1?record:min_index+1;
}
return;
}
边栏推荐
- jz2440---使用uboot烧录程序
- How does flutter transfer parameters to the next page when switching pages?
- 3 big questions! Redis cache exceptions and handling scheme summary
- 安装 新版本cmake & swig & tinyspline
- Click the mask layer to close the pop-up window
- The first problem troubleshooting process of re disk
- Several connection query methods of SQL (internal connection, external connection, full connection and joint query)
- Regular expression learning
- MapReduce&Yarn理论
- thinkphp5使用composer安装插件提示php版本过高
猜你喜欢

Spark based distributed parallel processing optimization strategy - Merrill Lynch data

逻辑英语结构【重点】

Comprehensive interpretation! Use of generics in golang

"One week's work on Analog Electronics" - optocoupler and other components

Joint Noise-Tolerant Learning and Meta Camera Shift Adaptation for Unsupervised Person Re-ID

Cancellation and unbinding of qiniu cloud account

"One week's data collection" - logic gate

Shared by Merrill Lynch data technology expert team, smoking detection related practice based on Jetson nano

How to solve the sample imbalance problem in machine learning?
![[pulsar learning] pulsar Architecture Principle](/img/ec/5ab9aabc2beafd4238dc8055ba6fb2.png)
[pulsar learning] pulsar Architecture Principle
随机推荐
2021年全国职业院校技能大赛(中职组)网络安全竞赛试题(2)详解
How does flutter transfer parameters to the next page when switching pages?
英语常用短语
Classified catalogue of high quality sci-tech periodicals in the field of computing
There is a strong demand for enterprise level data integration services. How to find a breakthrough for optimization?
Origin of QPM
2021-11-12 vrep vision sensor configuration
【CVPR 2019】Semantic Image Synthesis with Spatially-Adaptive Normalization(SPADE)
install opencv-contrib-dev to use aruco code
GAN Inversion: A Survey
CVPR:Refining Pseudo Labels with Clustering Consensus over Generations for Unsupervised Object Re-ID
Introduction to QPM
Detailed explanation of the network security competition questions (2) of the 2021 national vocational college skills competition (secondary vocational group)
Edge computing is the sinking and extension of cloud computing capabilities to the edge and user sides
Jz2440--- using uboot burning program
Halcon photometric stereoscopic
The first problem troubleshooting process of re disk
Throttling, anti chattering, new function, coriolism
Industrial and enterprise patent matching data (hundreds of thousands of data) 1998-2014
异常记录-23