LeetCode || Search a 2D Matrix II
2015-09-05 11:15
363 查看
class Solution { public: bool searchMatrix(vector<vector<int>>& matrix, int target) { int row = matrix.size(); if(row == 0) return false; int col = matrix[0].size(); if(col == 0) return false; int i = 0; int j = col -1; while( i < row && j >= 0) { if(matrix[i][j] == target) return true; if(matrix[i][j] > target) { j--; } else i++; } return false; } };
相关文章推荐
- 零基础学python-11.2 python语法规则
- 零基础学python-11.2 python语法规则
- HashMap源码分析
- ABAP笔记:BDC完整版例子
- OC开发之备份CSDN博客到本地
- Ruby 学习之开始
- 新手WEB开发者易出现的30个问题(转)
- Composer 安装
- 使用Session防止表单重复提交
- C++类型装换
- android6.0进入Material Design时代
- ATS 5.3.0缓存架构
- android-百度地图
- N个结点的连通图的边数问题
- Rails之美
- Rails常用命令整理
- Longest Substring Without Repeating Characters
- HDU3694 Fermat Point in Quadrangle(求四边形费马点)
- [HDOJ5384]Danganronpa
- 数据处理——两文件快速对接