当前位置:网站首页>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;
}
边栏推荐
- How to teach yourself to learn programming
- Exercise 9-4 finding books (20 points)
- Latex arranges single column table pictures in double column format articles
- Exercise 7-4 find out the elements that are not common to two arrays (20 points)
- 什么是 DevSecOps?2022 年的定义、流程、框架和最佳实践
- Golang type comparison
- 2021-08-11 function pointer
- Pcl:: fromrosmsg alarm failed to find match for field 'intensity'
- Latex error: missing delimiter (. Inserted) {\xi \left( {p,{p_q}} \right)} \right|}}
- Velodyne configuration command
猜你喜欢
Advanced technology management - how to design and follow up the performance of students at different levels
uniapp 小于1000 按原数字显示 超过1000 数字换算成10w+ 1.3k+ 显示
A little feeling
[FAQ] summary of common causes and solutions of Huawei account service error 907135701
基于线性函数近似的安全强化学习 Safe RL with Linear Function Approximation 翻译 2
【Day1】 deep-learning-basics
转载:等比数列的求和公式,及其推导过程
If you don't know these four caching modes, dare you say you understand caching?
[200 opencv routines] 218 Multi line italic text watermark
Today's sleep quality record 78 points
随机推荐
按键精灵跑商学习-商品数量、价格提醒、判断背包
Ruby time format conversion strftime MS matching format
Golang defer
六月份阶段性大总结之Doris/Clickhouse/Hudi一网打尽
C language pointer interview question - the second bullet
Safety reinforcement learning based on linear function approximation safe RL with linear function approximation translation 2
Some summaries of the third anniversary of joining Ping An in China
Hands on deep learning (40) -- short and long term memory network (LSTM)
uniapp 小于1000 按原数字显示 超过1000 数字换算成10w+ 1.3k+ 显示
Exercise 9-3 plane vector addition (15 points)
Pcl:: fromrosmsg alarm failed to find match for field 'intensity'
Hands on deep learning (46) -- attention mechanism
什么是 DevSecOps?2022 年的定义、流程、框架和最佳实践
RHCE day 3
Four characteristics and isolation levels of database transactions
2021-08-10 character pointer
From programmers to large-scale distributed architects, where are you (I)
Work order management system OTRs
On Multus CNI
Hands on deep learning (39) -- gating cycle unit Gru