摘要: 208. 实现 Trie (前缀树) class TrieNode { public: TrieNode() { isend = false; children.clear(); } bool isend; unordered_map<char, TrieNode*> children; }; cl 阅读全文
posted @ 2025-08-27 09:53 skyler886 阅读(6) 评论(0) 推荐(0)
摘要: 94. 城市间货物运输 I SPFA #include <iostream> #include <vector> #include <list> #include <climits> #include <queue> using namespace std; struct Node { int to 阅读全文
posted @ 2025-08-22 19:17 skyler886 阅读(4) 评论(0) 推荐(0)
摘要: 47. 参加科学大会(第六期模拟笔试) dijkstra(堆优化版)精讲 #include <iostream> #include <vector> #include <climits> #include <queue> #include <list> using namespace std; cl 阅读全文
posted @ 2025-08-20 15:36 skyler886 阅读(8) 评论(0) 推荐(0)
摘要: 53. 寻宝(第七期模拟笔试) prim #include <iostream> #include <vector> #include <climits> using namespace std; int main() { int v, e; cin >> v >> e; int v1, v2 , 阅读全文
posted @ 2025-08-19 12:37 skyler886 阅读(10) 评论(0) 推荐(0)
摘要: 并查集 int n = 1005; // n根据题目中节点数量而定,一般比节点数量大一点就好 vector<int> father = vector<int> (n, 0); // C++里的一种数组结构 vector<int> rank = vector<int> (n, 1); // 初始每棵树 阅读全文
posted @ 2025-08-18 11:15 skyler886 阅读(9) 评论(0) 推荐(0)
摘要: 106. 岛屿的周长 #include <iostream> #include <vector> #include <queue> using namespace std; int dir[4][2] = {0, 1, 1, 0, -1, 0, 0, -1}; int bfs(vector<vect 阅读全文
posted @ 2025-08-17 10:57 skyler886 阅读(5) 评论(0) 推荐(0)
摘要: 101. 孤岛的总面积 #include <iostream> #include <vector> #include <queue> using namespace std; int dirt[4][2] = {0, 1, 1, 0, -1, 0, 0, -1}; void bfs(vector<v 阅读全文
posted @ 2025-08-16 22:15 skyler886 阅读(5) 评论(0) 推荐(0)
摘要: 99. 岛屿数量 dfs: #include <iostream> #include <vector> using namespace std; int result = 0; vector<vector<int>> dirt = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}} 阅读全文
posted @ 2025-08-15 09:51 skyler886 阅读(6) 评论(0) 推荐(0)
摘要: 115. 不同的子序列 class Solution { public: int numDistinct(string s, string t) { int result = 0; vector<vector<uint64_t>> dp(s.size() + 1, vector<uint64_t>( 阅读全文
posted @ 2025-08-14 11:44 skyler886 阅读(5) 评论(0) 推荐(0)
摘要: 718. 最长重复子数组 class Solution { public: int findLength(vector<int>& nums1, vector<int>& nums2) { vector<vector<int>> dp(nums1.size() + 1, vector<int>(nu 阅读全文
posted @ 2025-08-13 09:52 skyler886 阅读(5) 评论(0) 推荐(0)