当前位置:网站首页>Sword finger offer 04 Search in two-dimensional array
Sword finger offer 04 Search in two-dimensional array
2022-07-05 05:28:00 【ThE wAlkIng D】
Title Description
Problem analysis
- Notice how the two-dimensional array is incremented , Locate the lower left corner as the starting point and start traversal according to the incremental method
- Be careful .length( For any array , Take out its capacity ) and .length()( For Strings ) The difference between
Code instance
class Solution {
public boolean findNumberIn2DArray(int[][] array, int target) {
int row = array.length - 1;
int col = 0;
while(row >= 0 && (col<array[0].length){
if(array[row][col] > target){
row--;
}
else if(array[row][col] < target){
col++;
}
else{
return true;
}
}
return false;
}
}
边栏推荐
- Count sort
- On-off and on-off of quality system construction
- Haut OJ 1321: mode problem of choice sister
- Control Unit 控制部件
- Reader writer model
- The number of enclaves
- After setting up the database and website When you open the app for testing, it shows that the server is being maintained
- lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
- Talking about JVM (frequent interview)
- Palindrome (csp-s-2021-palin) solution
猜你喜欢
随机推荐
利用HashMap实现简单缓存
High precision subtraction
Insert sort
Solon Logging 插件的添加器级别控制和日志器的级别控制
Count sort
Animation scoring data analysis and visualization and it industry recruitment data analysis and visualization
Haut OJ 1245: large factorial of CDs --- high precision factorial
C语言杂谈1
[turn to] MySQL operation practice (III): table connection
Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail
远程升级怕截胡?详解FOTA安全升级
What is the agile proportion of PMP Exam? Dispel doubts
object serialization
Programmers' experience of delivering takeout
Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
Romance of programmers on Valentine's Day
Talking about JVM (frequent interview)
Reflection summary of Haut OJ freshmen on Wednesday
搭建完数据库和网站后.打开app测试时候显示服务器正在维护.