【练习笔记】剑指offer-面试题3 :二维数组中的查找
来源:互联网 发布:关闭数据还用流量 编辑:程序博客网 时间:2024/04/29 17:03
【题目】
在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。
【解答】
public class Solution { public boolean Find(int [][] array,int target) { if(array == null){ return false; }int x = 0; int y = array[0].length-1; while(x < array.length && y >= 0){ if(array[x][y] > target){ y-=1; }else if(array[x][y] < target){ x+=1; }else if(array[x][y] == target){ return true; } } return false; }}
0 0
- 【练习笔记】剑指offer-面试题3 :二维数组中的查找
- 【剑指offer】面试题3:二维数组中的查找
- 【剑指offer】面试题3:二维数组中的查找
- 剑指Offer:面试题3 二维数组中的查找
- 《剑指Offer》面试题3:二维数组中的查找
- 剑指offer面试题3-二维数组中的查找
- 【剑指Offer学习】【面试题3 :二维数组中的查找】
- 二维数组中的查找(剑指offer面试题3)
- 【剑指offer】 面试题3: 二维数组中的查找
- 剑指Offer面试题3:二维数组中的查找
- 剑指Offer:面试题3 二维数组中的查找
- 剑指offer-面试题3:二维数组中的查找
- 剑指offer面试题3之二维数组中的查找
- 剑指offer面试题3—二维数组中的查找
- 剑指offer 面试题3 二维数组中的查找
- 剑指offer面试题3:二维数组中的查找
- 剑指offer面试题3:二维数组中的查找
- 剑指offer - 面试题3:二维数组中的查找
- 盘点那些年,被Oracle收购的公司
- linux服务器安装apache2和nodejs
- hdu 1299 Diophantus of Alexandria
- 筛选法求素数 打表
- UIView
- 【练习笔记】剑指offer-面试题3 :二维数组中的查找
- 线程间的通信(生产者与消费者)
- UVA107等比数列注意特判
- DRP问题系列——The Network Adapter could not establish the connection
- 新媒体“4U”理论
- 【NOIP2004】合唱队形题解
- checkBox多选支付列表的实现(可以跨屏幕实现多选并计算金额)
- Bundle savedInstanceState的作用
- 【Swift】学习笔记(七)——闭包