题目要求:Search in Rotated Sorted Array

Suppose a sorted array is rotated at some pivot unknown to you beforehand.

(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).

You are given a target value to search. If found in the array return its index, otherwise return -1.

You may assume no duplicate exists in the array.

代码如下:

class Solution {
public:
int search(int A[], int n, int target) { int index = -1; //题目简化成找到数组A中的元素位置……
for(int i = 0; i < n; i++){
if(A[i] == target){
index = i;
break;
}
} return index;
}
};

最新文章

  1. 基于VC的ACM音频编程接口压缩Wave音频(二)
  2. 众人口中的JAVASCRIPT
  3. QListWidget
  4. fuelux.tree用法
  5. 遍历对象所有属性(json对象)
  6. [.NET 即时通信SignalR] 认识SignalR (一)
  7. 为什么MB51本位币金额和采购订单历史本位币金额不一样?
  8. Xcode集成Google Test
  9. Gunner II(二分,map,数字转化)
  10. 漫谈并发编程(二):java线程的创建与基本控制
  11. hdu2602 Bone Collector (01背包)
  12. javaScript属性
  13. R语言︱决策树族——随机森林算法
  14. Clean http handlers in Go
  15. 新建项目到Jenkins中
  16. SpringBoot启动tomcat源码解读
  17. mysql的sql语句的性能诊断分析
  18. [ios]NSThread传值 NSValue传值
  19. Simple2D-24 Sprite 渲染树
  20. 利用MessageFormat实现短信模板的匹配

热门文章

  1. Python列表lists索引关于字符串小纪
  2. bash中选择结构、循环结构与break、continue
  3. How to: Debug X++ Code Running in .NET Business Connector [AX 2012]
  4. IAuthorizationFilter学习笔记(权限控制)以及非全局的filter
  5. .NET必知的EventCounters性能指标监视器
  6. Flutter(75):Sliver组件之SliverFixedExtentList
  7. 一致性(ECMAScript语法标准翻译)
  8. html中创建并调用vue组件的几种方法
  9. linux服务器间配置ssh免密连接
  10. 11.java设计模式之享元模式