- 博客(4)
- 收藏
- 关注
原创 Leetcode - 5. 最长回文子串
原题链接:https://leetcode-cn.com/problems/longest-palindromic-substring/ 暴力解法:时间复杂度: O(n2) 空间复杂度: O(n2) 解题思路: 枚举左节点和右节点,通过之前的状态转移 string longestPalindrome(string s) { int n = s.size(); if(n <= 1){ return s; } .
2022-04-04 17:35:47
211
原创 美团2021校招笔试-编程题(通用编程试题,第10场)
原题链接:https://www.nowcoder.com/question/next?pid=28665343&qid=1371128&tid=52589195 #include <bits/stdc++.h> using namespace std; //dp状态已当前节点p为根,左右区间范围为[l,r] 的子树的最小权值和 //状态转移:dp[i][j] = 左区间 + 有区间 + 两点之积 //方便状态转移 取结点0为根 则从dfs(1,n,0)递归 int d
2022-02-28 17:49:37
183
转载 使用埃氏晒 + bitset 快速打质数表
#include <bits/stdc++.h> using namespace std; using ll = long long; typedef pair<int, int> PII; #define inf 2e9 int n,m,c; const int N = 2e3 + 10; const int M = 5e3 + 10; int head[N],e[M],w[M],ne[M],idx; int dist[N]; bool st[N]; int g[N][N]; .
2021-11-16 15:17:00
89
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人