当前位置:网站首页>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;
}
边栏推荐
- RHCE - day one
- IPv6 comprehensive experiment
- Hands on deep learning (III) -- Torch Operation (sorting out documents in detail)
- MySQL develops small mall management system
- 7-17 crawling worms (15 points)
- Histogram equalization
- If you don't know these four caching modes, dare you say you understand caching?
- Rhcsa learning practice
- Mmclassification annotation file generation
- When I forget how to write SQL, I
猜你喜欢
SQL replying to comments
DDL statement of MySQL Foundation
Reasons and solutions for the 8-hour difference in mongodb data date display
leetcode842. Split the array into Fibonacci sequences
Hands on deep learning (46) -- attention mechanism
【Day2】 convolutional-neural-networks
Qtreeview+ custom model implementation example
Two way process republication + routing policy
For programmers, if it hurts the most...
【Day2】 convolutional-neural-networks
随机推荐
Hlk-w801wifi connection
PHP code audit 3 - system reload vulnerability
Kotlin: collection use
Exercise 7-3 store the numbers in the array in reverse order (20 points)
基于线性函数近似的安全强化学习 Safe RL with Linear Function Approximation 翻译 1
leetcode1-3
使用 C# 提取 PDF 文件中的所有文字(支持 .NET Core)
Hands on deep learning (46) -- attention mechanism
Realsense d435 d435i d415 depth camera obtains RGB map, left and right infrared camera map, depth map and IMU data under ROS
Development guidance document of CMDB
Rhcsa - day 13
【Day1】 deep-learning-basics
Exercise 9-3 plane vector addition (15 points)
RHCE day 3
uniapp 处理过去时间对比现在时间的时间差 如刚刚、几分钟前,几小时前,几个月前
Tables in the thesis of latex learning
Reprint: summation formula of proportional series and its derivation process
DCL statement of MySQL Foundation
Rhsca day 11 operation
View CSDN personal resource download details