剑指offer(旋转数组中的最小的数字)
来源:互联网 发布:无名的裘德 知乎 编辑:程序博客网 时间:2024/06/05 06:09
public class RotateNum {/*把一个数组最开始的若干个元素搬到数组的末尾, * 我们称之为数组的旋转。 * 输入一个非递减序列的一个旋转, * 输出旋转数组的最小元素。 * 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转, * 该数组的最小值为1。 * */ public int minNumberInRotateArray(int [] array) { if(array.length>0){ for(int i = array.length-1;i>0;i--){ if(array[i-1]>array[i]){ return array[i]; } } return array[0]; } else{ return 0; } }public static void main(String[] args) {RotateNum rotateNum = new RotateNum();int[] arr ={3,4,5,1,2,2};int i =rotateNum.minNumberInRotateArray(arr);System.out.println(i);}}
0 0
- 剑指offer(旋转数组中的最小的数字)
- 剑指Offer旋转数组中的最小数字
- 【剑指offer】旋转数组中的最小数字
- 剑指Offer:旋转数组中的最小数字
- 【剑指offer】旋转数组的最小数字
- 剑指offer--旋转数组的最小数字
- 剑指offer--旋转数组的最小数字
- 剑指offer:旋转数组的最小数字
- 《剑指offer》旋转数组的最小数字
- 剑指 offer:旋转数组的最小数字
- 剑指offer-旋转数组的最小数字
- 剑指offer 旋转数组的最小数字
- 【剑指offer】旋转数组的最小数字
- 剑指offer 旋转数组的最小数字
- 剑指offer-旋转数组的最小数字
- 剑指Offer:旋转数组的最小数字
- 剑指Offer 旋转数组的最小数字
- 剑指offer|旋转数组的最小数字
- TCP/IP 卷一 链路层
- 科目二相关事项
- Python Logging模块-Logger,Handler,Formatter
- linux内核编程实验三
- zoj3460(二分图,拆点,二分)
- 剑指offer(旋转数组中的最小的数字)
- POJ 2407 Relatives
- iOS学习使用NSURLSession
- 145. Binary Tree Postorder Traversal
- ElasticSearch教程(一)——简介与安装
- android GetWindow总结
- Android Studio 注解插件Android ButterKnife Zelezny使用教程
- 百度地图之定位
- leetcode 343 Interger Break