牛客网-《剑指offer》-二维数组中的查找
2016-01-07 17:13
369 查看
题目:http://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e
C++
C++
class Solution { public: bool Find(vector<vector<int> > array,int target) { int rows = array.size(); int cols = array[0].size(); int x = cols - 1; int y = 0; while ( x >= 0 && y < rows ) { if (array[x][y] == target) return true; if (array[x][y] < target) y++; if (array[x][y] > target) x--; } return false; } };
相关文章推荐
- JS date常用代码积累
- CSS Flex-box示例代码
- Lepus经历收获杂谈(一)——confirm features的小工具
- javascript中select下拉框的用法总结
- HTML <img> 标签的 alt 属性
- Javascript模块式编程小结
- 【转】39个让你受益的HTML5教程
- css3-动画
- node.js学习笔记之promise
- js中判断对象是否为空的方法
- 以下是JavaScript容易犯错的九个陷阱。
- easyui弹出层在最顶层显示跳出iframe框架通用javascript代码
- 详解JS中Array对象扩展与String对象扩展
- jquery eval解析JSON中的注意点介绍
- JSON.stringify()与JSON.parse()
- [React Testing] Children with Shallow Rendering
- jquery操作select(设置选中值,取选中值)
- CSS3的calc()使用
- 前端自动化学习笔记(一)——Yeoman,bower,Grunt的安装
- js创建对象的方法汇总