题解 | #二维数组中的查找#

二维数组中的查找

http://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e

public class Solution { public boolean Find(int target, int [][] array) { for(int i = 0;i < array.length;i++) { for(int j = 0;j < array[i].length;j++) { if(array[i][j] > target) break;//要注意如果出现了大于他的数,后面的数都比他大 if(array[i][j] == target) return true; } }

	return false;
}

}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务