当前位置:网站首页>Binary search
Binary search
2022-06-26 02:18:00 【51CTO】
One 、 Two points search
1. matrix
1.1 1351. Count the negative numbers in an ordered matrix
To give you one m * n Matrix grid, The elements of a matrix, whether by row or column , All in non increasing order . Please count and return grid in negative Number of .
Example 1:
Example 2:
1.2 74. Search for a two-dimensional matrix
Write an efficient algorithm to judge m x n Matrix , Is there a target value . The matrix has the following characteristics :
The integers in each row are arranged in ascending order from left to right .
The first integer in each row is greater than the last integer in the previous row .
Example 1:
Example 2:
Tips :
m == matrix.length
n == matrix[i].length
1 <= m, n <= 100
-104 <= matrix[i] [j], target <= 104
1.3 1337. The weakest in the matrix K That's ok
Give you a size of m * n Matrix mat, The matrix consists of a number of soldiers and civilians , Use them separately 1 and 0 Express .
Please return to the weakest in the matrix k Index of rows , Sort by weakest to strongest .
If the first i The number of soldiers in line is less than the number of j That's ok , Or two lines of soldiers in the same number but i Less than j, So we think the i The battle effectiveness of the line is better than the first j Row weakness .
Soldiers Always The front position in a row , in other words 1 Always in 0 Before .
Example 1:
Example 2:
Tips :
m == mat.length
n == mat[i].length
2 <= n, m <= 100
1 <= k <= m
matrix[i] [j] No 0 Namely 1
1.4 1346. Check the existence of integers and their multiples
Give you an array of integers arr, Please check whether there are two integers N and M, Satisfy N yes M Twice as many ( namely ,N = 2 * M).
More formally , Check if there are two subscripts i and j Satisfy :
i != j
0 <= i, j < arr.length
arr[i] == 2 * arr[j]
Example 1:
Example 2:
Example 3:
Tips :
2 <= arr.length <= 500
-10^3 <= arr[i] <= 10^3
Two 、 Conclusion
In the comment area, you can leave a message , Can be private , Can communicate and learn from each other , Common progress , You are welcome to give comments or comments , I am committed to high-quality articles .
Welcome to other excellent articles , I think it's great. You can put it away , Keep it for later use .
Personal blog Garden : https://www.cnblogs.com/fyphome
Personal blog : http://fyupeng.github.io/
Github Technical column : github.com/Fyupeng
Focus on quality , love your life .
Communication technology , Seek comrades .
—— Prolong the year QQ:1160886967
边栏推荐
猜你喜欢
随机推荐
Cross server SQL connection configuration
奶牛排序问题
数字商品DGE--数字经济的财富黑马
Abnova CMV CISH probe solution
Exploring temporary information for dynamic network embedding
【js】免费api判断节假日、工作日和周六日
树莓派 + AWS IoT 入门实验
Shell learning record (I)
Chemical properties and application of trypsin
Snake game
樹莓派 + AWS IoT Greengrass
Consumer of microservices
静态库动态库的使用
Ndk20b ffmpeg4.2.2 compilation and integration
cv==biaoding---open----cv001
.NET7之MiniAPI(特别篇) :Preview5优化了JWT验证(下)
@Query 疑难杂症
Cvpr2022 𞓜 future transformer with long-term action expectation
vs2015+PCL1.8.1+qt5.12-----(1)
Wechat launched a web version transmission assistant. Is it really easy to use?








![[untitled] vsbiji ESP thirty-two](/img/08/c479031c80d4dfdd8a05d530ae30ba.png)
