当前位置:网站首页>2022-1-6 Niuke net brush sword finger offer
2022-1-6 Niuke net brush sword finger offer
2022-07-03 09:09:00 【weixin_ thirty-seven million six hundred and eighty-two thousan】
JZ53 The number of times a number appears in an ascending array
error :class Solution {
public:
int GetNumberOfK(vector data ,int k) {
// Bubble sort
error 1// if(!data) return -1;
error 2// if(data.size==0) return -1;
int ans=0;
for(int i=0; i<data.size(); ++i){
// as long as data[i] And k equal ,ans++
//data[i]>k when break Stop the cycle
if(data[i] == k) ans++;
if(data[i]>k) break;
}
return ans;
}
};
error 1:
error 2: When the input is two parameters ,1 Is an array ,2 For the number to find in the array . About whether the two are empty 4 In this case :1 empty 2 empty ,1 empty 2 Not empty ,1 Not empty 2 empty ,1 Not empty 2 Not empty . In this question, you find numbers in an array , If 1 empty , It doesn't matter 2 How many , Will not find , No special treatment . If 1 Not empty ,2 There is no special treatment for several .
Insert picture description here
error 1: Calculation mid Should be mid = l+(r-l)/2
The mistake is mid = l+(l-r)/2 Insert picture description here
The official solution code is as follows
JZ11 Minimum number of rotation array
error : You should not set the minimum value yourself , Instead, a value in the array is used as the starting value .
JZ10 Fibonacci sequence
error : Logic error , If 0 or 1, Push the 1, Other situations , Push the vi[i-1] + vi[i-2]
JZ42 The maximum sum of successive subarrays
error :vector Assignment cannot be used dp[0]= Should use the dp.push_back(
边栏推荐
- The method of replacing the newline character '\n' of a file with a space in the shell
- LeetCode 75. Color classification
- Data mining 2021-4-27 class notes
- Summary of methods for counting the number of file lines in shell scripts
- The difference between if -n and -z in shell
- dried food! What problems will the intelligent management of retail industry encounter? It is enough to understand this article
- Solution of 300ms delay of mobile phone
- LeetCode 535. Encryption and decryption of tinyurl
- AcWing 785. Quick sort (template)
- Use the interface colmap interface of openmvs to generate the pose file required by openmvs mvs
猜你喜欢
【点云处理之论文狂读经典版13】—— Adaptive Graph Convolutional Neural Networks
推荐一个 yyds 的低代码开源项目
教育信息化步入2.0,看看JNPF如何帮助教师减负,提高效率?
[point cloud processing paper crazy reading classic version 9] - pointwise revolutionary neural networks
Tree DP acwing 285 A dance without a boss
LeetCode 513. Find the value in the lower left corner of the tree
【点云处理之论文狂读经典版11】—— Mining Point Cloud Local Structures by Kernel Correlation and Graph Pooling
State compression DP acwing 91 Shortest Hamilton path
【点云处理之论文狂读经典版14】—— Dynamic Graph CNN for Learning on Point Clouds
【点云处理之论文狂读前沿版10】—— MVTN: Multi-View Transformation Network for 3D Shape Recognition
随机推荐
On the difference and connection between find and select in TP5 framework
Convert video to GIF
Vs2019 configuration opencv3 detailed graphic tutorial and implementation of test code
Methods of checking ports according to processes and checking processes according to ports
Six dimensional space (C language)
LeetCode 1089. Duplicate zero
AcWing 788. Number of pairs in reverse order
LeetCode 324. 摆动排序 II
LeetCode 438. 找到字符串中所有字母异位词
Education informatization has stepped into 2.0. How can jnpf help teachers reduce their burden and improve efficiency?
The method of replacing the newline character '\n' of a file with a space in the shell
With low code prospect, jnpf is flexible and easy to use, and uses intelligence to define a new office mode
记忆化搜索 AcWing 901. 滑雪
Using variables in sed command
Character pyramid
Save the drama shortage, programmers' favorite high-score American drama TOP10
STM32F103 can learning record
[point cloud processing paper crazy reading classic version 9] - pointwise revolutionary neural networks
TP5 order multi condition sort
[point cloud processing paper crazy reading classic version 10] - pointcnn: revolution on x-transformed points