题目如下: Given words first and second, consider occurrences in some text of the form "first second third", where second comes immediately after first, and third comes immediately after second. For each such occurrence, add "third" to the…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字符串分割遍历 日期 题目地址:https://leetcode.com/problems/occurrences-after-bigram/ 题目描述 Given words first and second, consider occurrences in some text of the form "first second third&quo…
这道题目是典型的DFS+记忆化搜索, DP思想.符合:含重叠子问题,无后效性等特点. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 105 int dp[MAXN][MAXN]; int a[MAXN][MAXN]; int n, k; int max(int a, int b) { return a>b ? a:b; } int dfs(int x, int y) { i…
problem 1170. Compare Strings by Frequency of the Smallest Character 参考 1. Leetcode_easy_1170. Compare Strings by Frequency of the Smallest Character; 完…
problem 1160. Find Words That Can Be Formed by Characters solution class Solution { public: int countCharacters(vector<string>& words, string chars) { ; unordered_map<char, int> charmap; for(auto ch:chars) charmap[ch]++; for(auto word:word…
problem 997. Find the Town Judge solution: class Solution { public: int findJudge(int N, vector<vector<int>>& trust) { vector<); ]]--; balance[t[]]++; } ; i<=N; i++) { ) return i; } ; } }; 参考 1. Leetcode_easy_997. Find the Town Judge…
problem 985. Sum of Even Numbers After Queries class Solution { public: vector<int> sumEvenAfterQueries(vector<int>& A, vector<vector<int>>& queries) { vector<int> res; ; ==) sum +=a; for(auto query:queries) { ]]%== )…
problem 977. Squares of a Sorted Array solution: class Solution { public: vector<int> sortedSquares(vector<int>& A) { for(auto &a:A) a *=a; sort(A.begin(), A.end()); return A; } }; 参考1. Leetcode_easy_977. Squares of a Sorted Array; 完…