刷题
liuyi233
这个作者很懒,什么都没留下…
展开
-
LeetCode 5 最长回文子串
题目链接 动归即可通过,时间复杂度为O(n2)O(n^2)O(n2)。 C++代码(时间236ms,31.95%;空间8MB,69.37%): class Solution { public: string longestPalindrome(string s) { const int N = 1010; bool dp[N][N]; int l = s.length(); int ansStart = 0; int a原创 2021-04-28 05:08:52 · 49 阅读 · 0 评论 -
POJ 1651 矩阵链乘法
看《算法导论》上动态规划一章里有这个例子,找了个等价的题做做。 #include <iostream> #include <vector> #include <stdlib.h> #include <string> #include <cstring> using namespace std; const int MAXL = 2147483647; int main(){ int n; cin>>n; int原创 2021-04-27 14:24:19 · 107 阅读 · 0 评论