当前位置:网站首页>Leecode brush questions record sword finger offer 11 Rotate the minimum number of the array
Leecode brush questions record sword finger offer 11 Rotate the minimum number of the array
2022-07-07 00:12:00 【Why is there a bug list】
topic
Move the first elements of an array to the end of the array , We call it rotation of arrays .
Give you a chance to exist repeat An array of element values numbers , It turns out to be an ascending array , And a rotation is carried out according to the above situation . Please return the smallest element of the rotation array . for example , Array [3,4,5,1,2] by [1,2,3,4,5] A rotation of , The minimum value of the array is 1.
Example 1:
Input :[3,4,5,1,2]
Output :1
Example 2:
Input :[2,2,2,0,1]
Output :0
answer
class Solution {
public int minArray(int[] numbers) {
for(int i=0;i<numbers.length;i++)
{
if(i+1==numbers.length) return numbers[0];
if(numbers[i]-numbers[i+1]>0)
return numbers[i+1];
}
return numbers[numbers.length-1];
}
}
边栏推荐
- 【2022全网最细】接口测试一般怎么测?接口测试的流程和步骤
- Data operation platform - data collection [easy to understand]
- Things like random
- 在docker中快速使用各个版本的PostgreSQL数据库
- How can computers ensure data security in the quantum era? The United States announced four alternative encryption algorithms
- Three application characteristics of immersive projection in offline display
- kubernetes部署ldap
- Sword finger offer 26 Substructure of tree
- Liuyongxin report | microbiome data analysis and science communication (7:30 p.m.)
- DevOps可以帮助减少技术债务的十种方式
猜你喜欢
MVC and MVVM
DAY ONE
Tourism Management System Based on jsp+servlet+mysql framework [source code + database + report]
【2022全网最细】接口测试一般怎么测?接口测试的流程和步骤
Racher integrates LDAP to realize unified account login
【精品】pinia 基于插件pinia-plugin-persist的 持久化
2022年PMP项目管理考试敏捷知识点(9)
The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
Geo data mining (III) enrichment analysis of go and KEGG using David database
Close unregistering application XXX with Eureka with status down after Eureka client starts
随机推荐
Why is bat still addicted to 996 when the four-day working system is being tried out in Britain?
Competition between public and private chains in data privacy and throughput
Wechat applet UploadFile server, wechat applet wx Uploadfile[easy to understand]
matplotlib画柱状图并添加数值到图中
How to use vector_ How to use vector pointer
【CVPR 2022】半监督目标检测:Dense Learning based Semi-Supervised Object Detection
What is web penetration testing_ Infiltration practice
使用yum来安装PostgreSQL13.3数据库
Wind chime card issuing network source code latest version - commercially available
37页数字乡村振兴智慧农业整体规划建设方案
在Docker中分分钟拥有Oracle EMCC 13.5环境
PostgreSQL highly available repmgr (1 master 2 slave +1witness) + pgpool II realizes master-slave switching + read-write separation
【CVPR 2022】目标检测SOTA:DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection
Unity 颜色板|调色板|无级变色功能
GEO数据挖掘(三)使用DAVID数据库进行GO、KEGG富集分析
[vector retrieval research series] product introduction
okcc呼叫中心的订单管理时怎么样的
DAY TWO
Automatic test tool katalon (WEB) test operation instructions
Common modification commands of Oracle for tables