当前位置:网站首页>Sword finger offer 04: find in 2D array
Sword finger offer 04: find in 2D array
2022-06-11 05:46:00 【swindler.】
Two dimensional array search
Their thinking : Find elements in an ordered array , You should start with the vertex , This topic starts from the vertex in the lower left corner , In turn target Compare with the elements in an ordered array
class Solution {
func findNumberIn2DArray(_ matrix: [[Int]], _ target: Int) -> Bool {
var row = matrix.count - 1
var col = 0
while row >= 0 && col <= matrix[0].count - 1 {
if matrix[row][col]>target{
row -= 1
}
else if matrix[row][col]<target{
col += 1
}
else{
return true
}
}
return false
}
}
边栏推荐
- SwiftUI: Navigation all know
- es-ik 安装报错
- Install Oracle Database
- VSCode插件开发
- Concepts and differences of parallel computing, distributed computing and cluster (to be updated for beginners)
- NDK learning notes (13) create an avi video player using avilib+opengl es 2.0
- 35. search insertion position
- Control your phone with genymotion scratch
- 使用Genymotion Scrapy控制手机
- Project - Smart City
猜你喜欢

Wechat custom component - style - slot

Analyze while doing experiments -ndk article -jni uses registernatives for explicit method registration

NDK R21 compiles ffmpeg 4.2.2+x264 and converts video files using ffmpeg

NDK learning notes (13) create an avi video player using avilib+opengl es 2.0

Customize the layout of view Foundation

袋鼠云数栈基于CBO在Spark SQL优化上的探索

(15) Infrared communication

NFC Development -- utility tools and development documents (IV)

Control your phone with genymotion scratch

YOLOv5的Tricks | 【Trick8】图片采样策略——按数据集各类别权重采样
随机推荐
Multithreading tutorial (XXVIII) unsafe class
创建酷炫的 CollectionViewCell 转换动画
Aurora im live chat
Clear function of ArrayList
Stone game -- leetcode practice
[go deep into kotlin] - get to know flow for the first time
What is a thread pool?
Mingw-w64 installation instructions
NDK learning notes (12) native graphics API, using avilib to create an avi video player
Wxparse parsing iframe playing video
Bert knowledge distillation
MySQL circulates multiple values foreach, XML writing method
NDK learning notes (13) create an avi video player using avilib+opengl es 2.0
NFC Development -- utility tools and development documents (IV)
qmake 实现QT工程pro脚本转vs解决方案
Xposed bypasses 360 reinforcement to get a real classloader
Multi threading tutorial (XXIV) cas+volatile
Dism command usage summary
使用Batch枚举文件
袋鼠云数栈基于CBO在Spark SQL优化上的探索