LintCode
qq_30163523
这个作者很懒,什么都没留下…
展开
-
【原创,禁止转载】单词拆分问题
解决思路采用字典树查询提高查询效率中间可能需要回溯,用堆栈保存需要回溯的状态#include <iostream> #include <set> #include <vector> #include <unordered_set> #include <unordered_map>using namespace std; class Solution { public: /* * @p原创 2017-12-30 11:11:02 · 712 阅读 · 0 评论 -
【原创】最长公共子序列
dp[i][j] 表示第一个字符串的前i个字符与第二个字符的前j个字符构成的公共子序列的长度最优子结构: #include <iostream> #include <string> #include <vector> #include <set> using namespace std; class Solution { public: /* * @param A: A strin原创 2017-12-30 11:24:49 · 182 阅读 · 0 评论 -
背包问题2
最优子结构: #include <iostream> #include <vector>using namespace std;class Solution { public: /** * @param m: An integer m denotes the size of a backpack * @param A: Given n items with size A[i原创 2017-12-30 11:38:48 · 218 阅读 · 0 评论 -
【原创】背包问题
思路:动态规划。背包剩余容量为j,已决定前i个物品是否放入时,最大价值为dp[i][j](此问题中为放入的物品总重量)最优子结构: #include <iostream> #include <vector>using namespace std;class Solution { public: /** * @param m: An integer m denotes the siz原创 2017-12-30 11:33:10 · 185 阅读 · 0 评论