随笔分类 - 培训系列
摘要:class Solution { public: string largestMerge(string word1, string word2) { string ans; int i = 0, j = 0; while (i < word1.size() || j < word2.size())
阅读全文
摘要:简单的模拟 class Solution { public: int finalValueAfterOperations(vector<string>& operations) { int ans = 0; for (auto str : operations) { if (str[0] == 'X
阅读全文
摘要:【LC1799】 class Solution { public: int n; vector<int> dp; //状态DP; vector<vector<int>> gcd; //gcd<i, j>:nums[i], nums[j] gcd的结果; int GCD(int x, int y) {
阅读全文
摘要:Trie树 Trie树也叫字典树。 主要是用于多个字符串中与某个字符串的匹配,也是AC自动机的一个基础。 Trie树的好处在于匹配时只需要O(N)算法即可完成,如果使用暴力则需要O(MN),这就是一种优化。 Trie树的实现 一般是利用多个数组来模拟树的链接关系。 为了简单起见,我们只考虑小写字母的
阅读全文
摘要:https://leetcode.cn/problems/implement-magic-dictionary/ static int son[10010][26]; int idx = 0; static int cnt[10010]; class MagicDictionary { public
阅读全文
摘要:[LC2300] class Solution { public: using LL = long long; vector<int> successfulPairs(vector<int>& spells, vector<int>& potions, long long success) { //
阅读全文