Lucas1101
Lucas1101
全部文章
分类
题解(7)
归档
标签
去牛客网
登录
/
注册
爱敲代码的小卜
全部文章
(共9篇)
题解 | #比较版本号#
比较简单的思路 class Solution { public: int compare(string version1, string version2) { &n...
C++
2022-08-21
0
151
题解 | #二叉搜索树的最近公共祖先#
直接递归,思路清晰 class Solution { public: int lowestCommonAncestor(TreeNode* root, int p, int&nb...
二叉搜索树
二叉树
C++
递归
2022-06-23
1
237
题解 | #密码截取#
经典题目,注意代码规范 #include <bits/stdc++.h> using namespace std; int maxLength (const string str, int l, int r) { while (l >= 0 && r < ...
C++
2022-03-30
1
182
题解 | #合唱队#
动态规划,注意代码规范 #include <bits/stdc++.h> using namespace std; int main () { int n; cin >> n; vector<int> nums(n, 0); vector<int&g...
C++
2022-03-30
0
204
题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
这道题就很简单了,注意代码规范 #include <bits/stdc++.h> using namespace std; int main () { double n; cin >> n; double sum = 0; double tem = n; for (...
C++
2022-03-30
0
190
题解 | #查找兄弟单词#
这道题很多坑,详细看我的xd函数 #include <bits/stdc++.h> using namespace std; vector<string> xd (vector<string>& str, string s) { vector<st...
C++
2022-03-29
0
217
题解 | #计算某字符出现次数#
哈希表,极致占用内存,注意代码规范 #include <bits/stdc++.h> using namespace std; int main () { unordered_map<char, int>rec; string str; getline(cin, str...
C++
2022-03-28
0
177
题解 | #密码验证合格程序#
注意代码规范,自己写的(仅供参考) #include <bits/stdc++.h> using namespace std; bool chongFu (string str) { int n = str.size(); set<string> rec; for (i...
C++
2022-03-28
1
252
题解 | #坐标移动#
思路明确,注意代码规范 #include <bits/stdc++.h> using namespace std; void zbyd(int& j, int& k, char c, int m) { if (c == 'A') j -= m; if (c == 'S...
C++
2022-03-28
1
248