当前位置:网站首页>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];
}
}
边栏推荐
- Introduction to GPIO
- C language input / output stream and file operation [II]
- ldap创建公司组织、人员
- 基于SSM框架实现的房屋租赁管理系统
- 使用源码编译来安装PostgreSQL13.3数据库
- Use type aliases in typescript
- Oracle中使用包FY_Recover_Data.pck来恢复truncate误操作的表
- 编译logisim
- Pytest multi process / multi thread execution test case
- Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform
猜你喜欢
After leaving a foreign company, I know what respect and compliance are
How can computers ensure data security in the quantum era? The United States announced four alternative encryption algorithms
The largest single investment in the history of Dachen was IPO today
Business process testing based on functional testing
Server SMP, NUMA, MPP system learning notes.
GPIO简介
Devops can help reduce technology debt in ten ways
48页数字政府智慧政务一网通办解决方案
Newsletter L Huobi ventures is in-depth contact with genesis public chain
Imeta | Chen Chengjie / Xia Rui of South China Agricultural University released a simple method of constructing Circos map by tbtools
随机推荐
谷歌百度雅虎都是中国公司开发的通用搜索引擎_百度搜索引擎url
Every year, 200 billion yuan is invested in the chip field, and "China chip" venture capital is booming
PDF文档签名指南
Operation test of function test basis
The largest single investment in the history of Dachen was IPO today
DAY FIVE
Personal digestion of DDD
使用yum来安装PostgreSQL13.3数据库
ldap创建公司组织、人员
Quickly use various versions of PostgreSQL database in docker
(leetcode) sum of two numbers
Imeta | Chen Chengjie / Xia Rui of South China Agricultural University released a simple method of constructing Circos map by tbtools
在Docker中分分钟拥有Oracle EMCC 13.5环境
Three sentences to briefly introduce subnet mask
[2022 the finest in the whole network] how to test the interface test generally? Process and steps of interface test
1000字精选 —— 接口测试基础
Unity color palette | color palette | stepless color change function
【向量检索研究系列】产品介绍
"Latex" Introduction to latex mathematical formula "suggestions collection"
Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform