240. Search a 2D Matrix II
2016-04-24 18:02
447 查看
//O(m+n) 220ms class Solution { public: bool searchMatrix(vector<vector<int>>& m, int t) { int a=m.size(),b=m[0].size(); if(a*b==0||m[0][0]>t||m[a-1][b-1]<t) return false; int x=0,y=b-1; while(x<a&&y>=0) { if(m[x][y]==t) return true; if(m[x][y]<t) x++; else y--; } return false; } };
相关文章推荐
- git操作详解
- PV(访问量)、UV(独立访客)、IP(独立IP) (转)
- 使用gulp-sass 和 gulp-livereload 自动编译sass文件
- C++ primer
- Unity学习笔记四 - Survival Shooter Tutorial
- 心碎的Basic SQL&Assignment
- MyEclipse做的项目导入到Eclipse中错误
- spring aop的xml配置详解
- Android Framework Java层是如何拦截并分发底层传送来的按键事件
- Linux初认识(一)
- View生成Bitmap
- c中数据的存储(内存)
- 从零开始学动态规划
- eclipse开发velocity实例(初学)
- PHP手工注入
- JavaScript常用字符串与数组扩展函数小结
- stc跟踪算法的一点优化
- ERROT: SampleCB() - buffer sizes do not match 解决方案
- jQuery EasyUI基础组件(panel,window,dialog)
- xib文件使用