当前位置:网站首页>剑指 Offer 11. 旋转数组的最小数字
剑指 Offer 11. 旋转数组的最小数字
2022-07-03 12:10:00 【嗝~~~~】
剑指 Offer 11. 旋转数组的最小数字
难度简单626收藏分享切换为英文接收动态反馈
把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。
给你一个可能存在 重复 元素值的数组 numbers ,它原来是一个升序排列的数组,并按上述情形进行了一次旋转。请返回旋转数组的最小元素。例如,数组 [3,4,5,1,2] 为 [1,2,3,4,5] 的一次旋转,该数组的最小值为 1。
注意,数组 [a[0], a[1], a[2], …, a[n-1]] 旋转一次 的结果为数组 [a[n-1], a[0], a[1], a[2], …, a[n-2]] 。
示例 1:
输入:
numbers =
[3,4,5,1,2]输出:1
示例 2:
输入:
numbers =
[2,2,2,0,1]输出:0
提示:
- n == numbers.length
- 1 <= n <= 5000
- -5000 <= numbers[i] <= 5000
- numbers 原来是一个升序排序的数组,并进行了 1 至 n 次旋转
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;
}
};
边栏推荐
- Tensorflow binary installation & Failure
- 阿里大于发送短信(用户微服务--消息微服务)
- Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)
- Exploration of sqoop1.4.4 native incremental import feature
- 【判断题】【简答题】【数据库原理】
- 2021 autumn Information Security Experiment 1 (password and hiding technology)
- The latest version of lottery blind box operation version
- Swift return type is a function of function
- GCN thinking - word2vec directly calculates text classification
- node的ORM使用-Sequelize
猜你喜欢

Xctf mobile--app3 problem solving

Swift bit operation exercise

社交社区论坛APP超高颜值UI界面

Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)

Node. Js: use of express + MySQL

【ArcGIS自定义脚本工具】矢量文件生成扩大矩形面要素

自抗扰控制器七-二阶 LADRC-PLL 结构设计

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

Day 1 of kotlin learning: simple built-in types of kotlin

低代码平台国际化多语言(i18n)技术方案
随机推荐
How to stand out quickly when you are new to the workplace?
Gan totem column bridgeless boost PFC (single phase) seven PFC duty cycle feedforward
An example of newtonjason
Sword finger offer14 the easiest way to cut rope
Using swift language features, write a pseudo-random number generator casually
Approve iPad, which wants to use your icloud account
Redhat5 installing socket5 proxy server
并网-低电压穿越与孤岛并存分析
The latest version of blind box mall thinkphp+uniapp
Analysis of the influence of voltage loop on PFC system performance
【综合题】【数据库原理】
Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)
alright alright alright
Togaf certification self-study classic v2.0
【数据库原理及应用教程(第4版|微课版)陈志泊】【第五章习题】
[Exercice 5] [principe de la base de données]
Glide question you cannot start a load for a destroyed activity
【ArcGIS自定义脚本工具】矢量文件生成扩大矩形面要素
C graphical tutorial (Fourth Edition)_ Chapter 18 enumerator and iterator: enumerator samplep340
【数据库原理及应用教程(第4版|微课版)陈志泊】【第四章习题】