当前位置:网站首页>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;
}
边栏推荐
- Ruby时间格式转换strftime毫秒匹配格式
- 入职中国平安三周年的一些总结
- leetcode1-3
- Safety reinforcement learning based on linear function approximation safe RL with linear function approximation translation 2
- Number of relationship models
- 有老师知道 继承RichSourceFunction自定义读mysql怎么做增量吗?
- Laravel文档阅读笔记-How to use @auth and @guest directives in Laravel
- For programmers, if it hurts the most...
- system design
- Basic principle of servlet and application of common API methods
猜你喜欢

BGP advanced experiment
如果不知道這4種緩存模式,敢說懂緩存嗎?

OSPF comprehensive experiment

When I forget how to write SQL, I

Intelligent gateway helps improve industrial data acquisition and utilization

Rhcsa learning practice
Summary of reasons for web side automation test failure

VLAN part of switching technology

Custom type: structure, enumeration, union

leetcode1-3
随机推荐
如果不知道這4種緩存模式,敢說懂緩存嗎?
Hlk-w801wifi connection
Hands on deep learning (41) -- Deep recurrent neural network (deep RNN)
Legion is a network penetration tool
Devop basic command
Basic data types of MySQL
Golang type comparison
Differences among opencv versions
leetcode1229. Schedule the meeting
Evolution from monomer architecture to microservice architecture
按键精灵跑商学习-商品数量、价格提醒、判断背包
OSPF comprehensive experiment
2020-03-28
For programmers, if it hurts the most...
Rhsca day 11 operation
Hands on deep learning (37) -- cyclic neural network
Advanced technology management - how to design and follow up the performance of students at different levels
原生div具有编辑能力
Dynamic memory management
DCL statement of MySQL Foundation