当前位置:网站首页>Jianzhi offer 04 (implemented in C language)
Jianzhi offer 04 (implemented in C language)
2022-07-04 10:24:00 【sqjddb】
In a n * m In a two-dimensional array , Each row is sorted in ascending order from left to right , Each column is sorted in ascending order from top to bottom . Please complete an efficient function , Enter such a two-dimensional array and an integer , Determine whether the array contains the integer .
bool findNumberIn2DArray(int** matrix, int matrixSize, int* matrixColSize, int target){
if(matrixSize==0||*matrixColSize==0)
return false;
for(int col=*matrixColSize-1,row=0;row<matrixSize&&col>=0;)
{
if(matrix[row][col]==target)
return true;
else if(matrix[row][col]>target)
col--;
else
row++;
}
return false;
}
边栏推荐
- Vanishing numbers
- Realsense of d435i, d435, d415, t265_ Matching and installation of viewer environment
- When I forget how to write SQL, I
- If the uniapp is less than 1000, it will be displayed according to the original number. If the number exceeds 1000, it will be converted into 10w+ 1.3k+ display
- Exercise 9-4 finding books (20 points)
- Exercise 8-7 string sorting (20 points)
- Exercise 7-3 store the numbers in the array in reverse order (20 points)
- leetcode729. My schedule 1
- Differences among opencv versions
- System. Currenttimemillis() and system Nanotime (), which is faster? Don't use it wrong!
猜你喜欢
Si vous ne connaissez pas ces quatre modes de mise en cache, vous osez dire que vous connaissez la mise en cache?
Hands on deep learning (41) -- Deep recurrent neural network (deep RNN)
system design
Hands on deep learning (42) -- bi-directional recurrent neural network (BI RNN)
Reasons and solutions for the 8-hour difference in mongodb data date display
Histogram equalization
Rhcsa12
Machine learning -- neural network (IV): BP neural network
Reprint: summation formula of proportional series and its derivation process
5g/4g wireless networking scheme for brand chain stores
随机推荐
Press the button wizard to learn how to fight monsters - identify the map, run the map, enter the gang and identify NPC
Basic data types of MySQL
Latex arranges single column table pictures in double column format articles
Hands on deep learning (40) -- short and long term memory network (LSTM)
Hands on deep learning (46) -- attention mechanism
Latex insert picture, insert formula
From programmers to large-scale distributed architects, where are you (2)
RHCE day 3
Idea SSH channel configuration
Map container
If you don't know these four caching modes, dare you say you understand caching?
Exercise 7-8 converting strings to decimal integers (15 points)
From programmers to large-scale distributed architects, where are you (I)
Differences among opencv versions
AUTOSAR from getting started to mastering 100 lectures (106) - SOA in domain controllers
Es entry series - 6 document relevance and sorting
原生div具有编辑能力
5g/4g wireless networking scheme for brand chain stores
Mmclassification annotation file generation
PHP code audit 3 - system reload vulnerability