当前位置:网站首页>Sword finger offer 11 Rotate the minimum number of the array
Sword finger offer 11 Rotate the minimum number of the array
2022-07-03 12:59:00 【Hiccup~~~~】
The finger of the sword Offer 11. Minimum number of rotation array
The difficulty is simple 626 Switch to English to receive dynamic feedback
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.
Be careful , Array [a[0], a[1], a[2], …, a[n-1]] Rotate once The result is an array [a[n-1], a[0], a[1], a[2], …, a[n-2]] .
Example 1:
Input :
numbers =
[3,4,5,1,2] Output :1
Example 2:
Input :
numbers =
[2,2,2,0,1] Output :0
Tips :
- n == numbers.length
- 1 <= n <= 5000
- -5000 <= numbers[i] <= 5000
- numbers It turns out to be an ascending array , And carried on 1 to n Second rotation
class Solution {
public:
int minArray(vector<int>& numbers) {
int m=5001;
for(int i=0;i<numbers.size();i++){
if(numbers[i]<m)
m=numbers[i];
}
return m;
}
};
边栏推荐
- Integer case study of packaging
- Ali & ant self developed IDE
- 剑指 Offer 17. 打印从1到最大的n位数
- Enable SASL authentication for memcached
- A large select drop-down box, village in Chaoyang District
- Pytext training times error: typeerror:__ init__ () got an unexpected keyword argument 'serialized_ options'
- context. Getexternalfilesdir() is compared with the returned path
- Sword finger offer14 the easiest way to cut rope
- Express abstract classes and methods
- Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)
猜你喜欢

IDEA 全文搜索快捷键Ctr+Shift+F失效问题

(latest version) WiFi distribution multi format + installation framework

【数据库原理及应用教程(第4版|微课版)陈志泊】【第三章习题】

GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈

Ali & ant self developed IDE
![[review questions of database principles]](/img/c3/81d192a40bcc4f5d72fcbe76c708bb.png)
[review questions of database principles]

剑指 Offer 12. 矩阵中的路径

电压环对 PFC 系统性能影响分析

studio All flavors must now belong to a named flavor dimension. Learn more

Application of ncnn Neural Network Computing Framework in Orange Pi 3 Lts Development Board
随机推荐
最新版抽奖盲盒运营版
How to stand out quickly when you are new to the workplace?
The solution to change the USB flash disk into a space of only 2m
Huffman coding experiment report
【计网】第三章 数据链路层(2)流量控制与可靠传输、停止等待协议、后退N帧协议(GBN)、选择重传协议(SR)
Express abstract classes and methods
A large select drop-down box, village in Chaoyang District
[exercice 7] [principe de la base de données]
sitesCMS v3.0.2发布,升级JFinal等依赖
Xctf mobile--app2 problem solving
Airflow installation jump pit
Xctf mobile--app3 problem solving
C graphical tutorial (Fourth Edition)_ Chapter 13 entrustment: delegatesamplep245
【Colab】【使用外部数据的7种方法】
Tensorflow binary installation & Failure
[judgment question] [short answer question] [Database Principle]
Analysis of a music player Login Protocol
IDEA 全文搜索快捷键Ctr+Shift+F失效问题
Approve iPad, which wants to use your icloud account
剑指 Offer 15. 二进制中1的个数