Leetcode#74||Search a 2D Matrix
来源:互联网 发布:联通网络信号怎么样 编辑:程序博客网 时间:2024/05/01 17:22
public class Solution { public boolean searchMatrix(int[][] matrix, int target) { if (matrix == null || matrix.length == 0 || matrix[0].length == 0) { return false; } int row = matrix.length; int col = matrix[0].length; int left = 0; int right = row * col - 1; while (left <= right) { int mid = left + (right - left) / 2; int x = mid / col; int y = mid % col; if (matrix[x][y] == target) { return true; } else if (matrix[x][y] < target) { left = mid + 1; } else { right = mid - 1; } } return false; }}
0 0
- Leetcode 74 Search a 2D Matrix
- LeetCode 74: Search A 2D Matrix
- LeetCode 74 Search a 2D Matrix
- [leetcode 74] Search a 2D Matrix
- [LeetCode 74]Search a 2D Matrix
- leetcode || 74、Search a 2D Matrix
- leetcode-74 Search a 2D Matrix
- Leetcode[74]-Search a 2D Matrix
- 【Leetcode】Search a 2D Matrix #74
- LeetCode(74) Search a 2D Matrix
- Leetcode #74 Search a 2D Matrix
- Leetcode #74 Search a 2D Matrix
- leetcode 74: Search a 2D Matrix
- Leetcode#74||Search a 2D Matrix
- leetcode 74 : Search a 2D Matrix
- [Leetcode]#74 Search a 2D Matrix
- 【leetcode】【74】Search a 2D Matrix
- leetcode 74:Search a 2D Matrix
- 编写大规模的C语言程序
- VS2012自带的 性能分析 工具使用实例
- android ListView之——BaseAdapter使用
- 采集ajax加载生成的网页
- .Net 雜談
- Leetcode#74||Search a 2D Matrix
- 深度学习(deep learning)如果有春天,先得摆脱高能耗高资源依赖的局面
- Linux————TCP/IP协议
- 基于深度优先算法的有向图环路检测
- 消息MSG、 获取消息GetMessage、消息过滤、第一个鼠标、键盘消息等
- Android点击应用Icon发生了什么
- Android Api Demos登顶之路(三十六)Fragment-->Custom Animation
- Hibernate 下载、安装和使用
- HDU 5399(简单数学)