数据结构与算法
Coding_Bug_Lu
这个作者很懒,什么都没留下…
展开
-
Leetcode 22. 括号生成
括号生成原创 2023-01-16 22:39:29 · 289 阅读 · 0 评论 -
Leetcode 10. 正则表达式匹配
正则表达式匹配原创 2023-01-13 16:57:16 · 179 阅读 · 0 评论 -
Leetcode 19. 删除链表的倒数第 N 个结点
删除链表的倒数第 N 个结点原创 2023-01-12 21:27:04 · 187 阅读 · 0 评论 -
Leetcode 11. 盛最多水的容器
盛最多水的容器原创 2023-01-12 16:59:08 · 165 阅读 · 0 评论 -
Leetcode 面试题 08.12. 八皇后
N皇后原创 2022-11-05 22:41:14 · 100 阅读 · 0 评论 -
回溯-排序
回溯排序原创 2022-11-05 19:49:28 · 59 阅读 · 0 评论 -
回溯-组合
回溯组合原创 2022-11-05 19:44:10 · 69 阅读 · 0 评论 -
Leetcode 78. 子集 && 90. 子集 II
给你一个整数数组 nums ,数组中的元素 互不相同 。返回该数组所有可能的子集(幂集)。解集 不能 包含重复的子集。你可以按 任意顺序 返回解集。原创 2022-11-04 21:44:36 · 99 阅读 · 0 评论 -
Leetcode 39. 组合总和
给你一个 无重复元素 的整数数组 candidates 和一个目标整数 target ,找出 candidates 中可以使数字和为目标数 target 的 所有 不同组合 ,并以列表形式返回。你可以按 任意顺序 返回这些组合。candidates 中的 同一个 数字可以 无限制重复被选取 。如果至少一个数字的被选数量不同,则两种组合是不同的。 对于给定的输入,保证和为 target 的不同组合数少于 150 个。原创 2022-11-04 17:11:26 · 71 阅读 · 0 评论 -
Leetcode 17. 电话号码的字母组合
给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。答案可以按 任意顺序 返回。给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。原创 2022-11-02 01:07:08 · 88 阅读 · 0 评论 -
Leetcode 2. 两数相加
给你两个 非空 的链表,表示两个非负的整数。它们每位数字都是按照 逆序 的方式存储的,并且每个节点只能存储 一位 数字。请你将两个数相加,并以相同形式返回一个表示和的链表。你可以假设除了数字 0 之外,这两个数都不会以 0 开头。原创 2022-10-31 22:14:28 · 77 阅读 · 0 评论 -
Leetcode 104. 二叉树的最大深度
给定一个二叉树,找出其最大深度。二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。说明: 叶子节点是指没有子节点的节点。原创 2022-10-31 11:25:18 · 49 阅读 · 0 评论 -
Leetcode 62. 不同路径
一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为 “Start” )。机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为 “Finish” )。问总共有多少条不同的路径?原创 2022-10-31 11:10:47 · 51 阅读 · 0 评论 -
Leetcode 113. 路径总和 II
路径总和 II原创 2022-10-31 10:58:18 · 63 阅读 · 0 评论 -
组合与全排列
组合和全排列原创 2022-10-28 23:49:42 · 84 阅读 · 0 评论 -
Leetcode 129. 求根节点到叶节点数字之和
求根节点到叶节点数字之和原创 2022-10-26 23:52:54 · 86 阅读 · 0 评论 -
Leetcode 64. 最小路径和
最小路径和原创 2022-10-26 23:21:42 · 58 阅读 · 0 评论 -
Leetcode 32 最长有效括号
最长有效括号原创 2022-10-16 15:54:40 · 125 阅读 · 0 评论 -
leetcode 3 无重复字符的最长子串
无重复字符的最长子串原创 2022-10-14 23:48:14 · 111 阅读 · 0 评论 -
Leetcode5. 最长回文子串
最长回文子串原创 2022-10-03 00:14:41 · 92 阅读 · 0 评论 -
Leetcode 215 数组中的第K个最大元素
第K大的数原创 2022-08-19 15:19:01 · 173 阅读 · 0 评论 -
Leetcode 912 排序数组
快排原创 2022-08-19 12:21:45 · 96 阅读 · 0 评论 -
BM51 数组中出现次数超过一半的数字
数组中出现次数超过一半的数字原创 2022-08-18 21:58:30 · 81 阅读 · 0 评论 -
Leetcode 72 编辑距离
编辑距离原创 2022-08-18 21:11:49 · 152 阅读 · 0 评论 -
Leetcode 122. 买卖股票的最佳时机 II
买卖股票原创 2022-08-17 23:26:31 · 84 阅读 · 0 评论 -
BM83 字符串变形
字符串变形原创 2022-08-16 10:09:45 · 83 阅读 · 0 评论 -
BM96 主持人调度(二)
主持人调度(二)原创 2022-08-15 12:20:06 · 78 阅读 · 0 评论 -
Leetcode 92. 反转链表 II
92. 反转链表 II原创 2022-08-15 10:59:23 · 107 阅读 · 0 评论 -
Leetcode 518. 零钱兑换 II
零钱兑换原创 2022-06-09 22:36:12 · 75 阅读 · 0 评论 -
Leetcode 474. 一和零
一和零原创 2022-06-09 15:46:51 · 61 阅读 · 0 评论 -
Leetcode 494. 目标和
目标和原创 2022-06-03 15:41:46 · 54 阅读 · 0 评论 -
Leetcode 1049. 最后一块石头的重量 II
最后一块石头的重量原创 2022-06-02 19:33:07 · 52 阅读 · 0 评论 -
0/1背包与完全背包
0/1背包原创 2022-06-02 17:29:54 · 76 阅读 · 0 评论 -
Leetcode 416. 分割等和子集
分割等和子集原创 2022-06-02 15:44:30 · 63 阅读 · 0 评论 -
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 · 77 阅读 · 0 评论 -
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 · 60 阅读 · 0 评论 -
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 · 80 阅读 · 0 评论 -
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 · 92 阅读 · 0 评论 -
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 · 92 阅读 · 0 评论 -
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 · 86 阅读 · 0 评论