- 博客(84)
- 收藏
- 关注

原创 利用Visual Studio将C++项目打包成DLL文件
静态链接库(Lib)与动态链接库(DLL)如果出于某种原因,不想将源代码暴露给别人,就需要使用到库。库有动态链接库和静态链接库。静态连接库就是把(lib)文件中用到的函数代码直接链接进目标程序,程序运行的时候不再需要其它的库文件。动态链接就是把调用的函数所在文件模块(DLL)和调用函数在文件中的位置等信息链接进目标程序,程序运行的时候再从DLL中寻找相应函数代码,因此需要相应DLL文件的支持。
2022-03-11 22:27:09
16540
4
原创 Leetcode 124. 二叉树中的最大路径和
空间复杂度:O(n)。最坏情况下,二叉树退化成一条链,递归需要 O(n) 的栈空间。时间复杂度:O(n),其中 n 为二叉树的节点个数。
2025-07-20 17:19:49
141
原创 Leetcode 78. 子集 && 90. 子集 II
给你一个整数数组 nums ,数组中的元素 互不相同 。返回该数组所有可能的子集(幂集)。解集 不能 包含重复的子集。你可以按 任意顺序 返回解集。
2022-11-04 21:44:36
143
原创 Leetcode 39. 组合总和
给你一个 无重复元素 的整数数组 candidates 和一个目标整数 target ,找出 candidates 中可以使数字和为目标数 target 的 所有 不同组合 ,并以列表形式返回。你可以按 任意顺序 返回这些组合。candidates 中的 同一个 数字可以 无限制重复被选取 。如果至少一个数字的被选数量不同,则两种组合是不同的。 对于给定的输入,保证和为 target 的不同组合数少于 150 个。
2022-11-04 17:11:26
98
原创 Leetcode 17. 电话号码的字母组合
给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。答案可以按 任意顺序 返回。给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。
2022-11-02 01:07:08
142
原创 HJ20 密码验证合格程序
代码#include <iostream>#include <string>using namespace std;bool check_char(string str) { // 核对大小写、数字、符号 int cate1 = 0, cate2 = 0, cate3 = 0, cate4 = 0; for (int i = 0; i < str.size(); i++) { if ( str[i] >= 'A' &a.
2022-05-27 22:18:50
101
原创 HJ15 求int型正整数在内存中存储时1的个数
代码#include <iostream>using namespace std;int main() { int num; while (cin >> num) { int m = 0; while (num) { m += num % 2; num /= 2; } cout << m << endl; }.
2022-05-27 17:35:21
82
原创 HJ12 字符串反转
代码#include <iostream>#include <string>#include <algorithm>#include <stack>using namespace std;int main() { string s; while (getline(cin, s)) {// reverse(s.begin(), s.end());// cout << s <&l.
2022-05-27 14:58:34
111
原创 HJ10 字符个数统计
哈希#include <iostream>#include <unordered_map>using namespace std;int main() { string str; while (cin >> str) { unordered_map<char, int> hash; for (auto ch : str) { if (hash.count(ch) == 0).
2022-05-19 20:41:48
134
原创 HJ8 合并表记录
哈希#include <iostream>#include <map>#include <unordered_map>using namespace std;int main() { int n; while (cin >> n) { map<int, int> tmp_map; for (int i = 0; i < n; i++) { int a, b.
2022-05-19 20:18:08
119
原创 HJ6 质数因子
#include <iostream>#include <math.h>using namespace std;int main() { int num; while (cin >> num) { int max = sqrt(num); for (int i = 2; i <= max; i++) { while (num % i == 0) { c.
2022-05-19 20:16:25
110
原创 HJ6 质数因子
#include <iostream>#include <math.h>using namespace std;int main() { int num; while (cin >> num) { int max = sqrt(num); for (int i = 2; i <= max; i++) { while (num % i == 0) { c.
2022-05-19 16:39:01
91
原创 HJ5 进制转换
#include <iostream>#include <string>#include <math.h>using namespace std;int main() { string s; while (cin >> s) { int bit = 0; int ans = 0; for (int i = s.size() - 1; i > 1; i--) { .
2022-05-19 16:10:26
184
原创 HJ4 字符串分隔
#include <iostream>using namespace std;int main() { string s; while (getline(cin, s)) { while (s.size() > 8) { cout << s.substr(0, 8) << endl; s = s.substr(8); } // s.resize(8.
2022-05-19 15:57:12
73
原创 HJ2 计算某字符出现次数
哈希表#include <iostream>#include <string.h>#include <unordered_map>using namespace std;int main() { string s; while (getline(cin, s)) { char target; cin >> target; unordered_map<char, int> .
2022-05-19 11:02:17
132
原创 HJ1 字符串最后一个单词的长度
代码#include <iostream>#include <string.h>using namespace std;int main() { string s; while (getline(cin, s)) { int index = s.size() - 1; int length = 0; while (s[index] == ' ') index--;.
2022-05-19 10:15:57
138
原创 Leetcode 70. 爬楼梯
状态转移方程代码class Solution {public: int climbStairs(int n) { if (n <= 2) return n; vector<int> dp(n + 1); dp[0] = 0; dp[1] = 1; dp[2] = 2; int a = 1, b =2, sum = 0; for (int i = 3; i <.
2022-05-13 22:14:29
147
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人