当前位置:网站首页>[jzof] 04 search in two-dimensional array
[jzof] 04 search in two-dimensional array
2022-07-24 21:05:00 【Sighed, angry】
describe
In a two-dimensional array array in ( Each one-dimensional array has the same length ), Each row is sorted in ascending order from left to right , Each column is sorted in ascending order from top to bottom . Please complete a function , Enter such a two-dimensional array and an integer , Determine whether the array contains the integer .
[
[1,2,8,9],
[2,4,9,12],
[4,7,10,13],
[6,8,11,15]
]
Given target = 7, return true.
Given target = 3, return false.
Ideas : Start from the lower left corner and traverse , If the number of targets is greater than the value of the current position , Then start to the right , Otherwise, go up .
Empathy , You can also traverse from the upper right corner .
public class Solution {
public boolean Find(int target,int [][] array) {
int row=0;
int col=array[0].length-1;
while(row<=array.length-1&&col>=0){
if(target==array[row][col])
return true;
else if(target>array[row][col])
row++;
else
col--;
}
return false;
}
}
边栏推荐
- Appium obtains and clicks coordinates, which is very easy to use when elements are inconvenient to locate
- Fluoronisin peptide nucleic acid oligomer complex | regular active group alkyne, SH thiol alkynyl modified peptide nucleic acid
- Open source demo | release of open source example of arcall applet
- Rce (no echo)
- How to buy Xinke financial products in CICC securities? Revenue 6%
- About the acid of MySQL, there are thirty rounds of skirmishes with mvcc and interviewers
- Lazily doing nucleic acid and making (forging health code) web pages: detained for 5 days
- When using vscode, the tab indentation changes from 4 spaces to small arrows (solved)
- Vscode connected to the remote server cannot format the code / document (resolved)
- Mitmproxy tampering with returned data
猜你喜欢

How to set appium script startup parameters

Easy to use office network optimization tool onedns

Do you want to enroll in a training class or study by yourself?
![[basic data mining technology] KNN simple clustering](/img/df/f4a3d9b8a636ea968c98d705547be7.png)
[basic data mining technology] KNN simple clustering

RESNET interpretation and 1 × 1 Introduction to convolution

Appium element positioning - App automated testing

How does starknet change the L2 landscape?

How to prevent weight under Gao Bingfa?

Upgrade appium automation framework to the latest 2.0

API data interface of A-share transaction data
随机推荐
[JVM] selection of garbage collector
One bite of Stream(7)
How to prevent weight under Gao Bingfa?
ECCV 2022 open source | target segmentation for 10000 frames of video
How to set the allure test report
Build your own stock analysis system based on b\s architecture
OpenGL (1) vertex buffer
High soft course summary
Lecun proposed that mask strategy can also be applied to twin networks based on vit for self supervised learning!
Leetcode 1928. minimum cost of reaching the destination within the specified time
Static & dynamic & file address book
How to buy Xinke financial products in CICC securities? Revenue 6%
[advanced data processing technology] data filtering, advanced data filling, initial and advanced data transformation
Native applets are introduced using vant webapp
Put apples
findContours
Modulenotfounderror: no module named 'pysat.solvers' (resolved)
驱动子系统开发
[training Day10] linear [mathematics] [thinking]
2022 chemical automation control instrument test question simulation test platform operation