剑指offer——旋转数组的最小数字
来源:互联网 发布:windows redis自启动 编辑:程序博客网 时间:2024/05/22 05:01
把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。
class Solution {public: int minNumberInRotateArray(vector<int> rotateArray) { //非递减数组的旋转,即找出第i个元素,rotateArray[i+1]>rotateArray[i] if(rotateArray.empty()) return 0; for(size_t i=0;i<rotateArray.size();++i){ if(rotateArray[i]>rotateArray[i+1]) return rotateArray[i+1]; } return rotateArray.front(); }};
阅读全文
0 0
- 剑指offer——旋转数组的最小数字
- 《剑指offer》——旋转数组的最小数字
- 剑指offer——旋转数组的最小数字
- 旋转数组的最小数字——剑指offer
- 剑指offer——旋转数组的最小数字
- 剑指offer——)旋转数组的最小数字
- 剑指offer——旋转数组的最小数字______
- 剑指offer——旋转数组的最小数字
- 剑指offer——6.旋转数组的最小数字
- 剑指offer——旋转数组的最小数字
- 剑指offer—旋转数组的最小数字
- 《剑指offer》—6、旋转数组的最小数字
- 剑指offer(6)—旋转数组的最小数字
- 剑指offer—旋转数组的最小数字
- 剑指offer—旋转数组的最小数字
- 【剑指offer】旋转数组的最小数字
- 剑指offer--旋转数组的最小数字
- 剑指offer--旋转数组的最小数字
- leetcode 661. Image Smoother
- Spring Boot忽略https证书:No subject alternative names present
- fetch请求
- git常用命令
- 正则表达式(一)
- 剑指offer——旋转数组的最小数字
- 深度学习: Nonlinear (非线性)
- 在ubuntu下安装jdk
- Beamer中数学符号字体
- nfs目录共享
- 数据库系统实现 第二章 辅助存储管理
- Android银行卡识别
- DOS 下使用 Git 命令
- UTF-8(无BOM)和UTF-8