当前位置:网站首页>Dynamic programming -- linear DP
Dynamic programming -- linear DP
2022-07-06 00:42:00 【Lin Shiliu should work hard】
1. Longest ascending subsequence (LIS)
Plain writing n^2
for(int i=1;i<=n;i++)
{
f[i]=1;
for(int j=1;j<i;j++)
if(a[i]>a[j])
f[i]=max(f[i],f[j]+1);
}
int m=0;
for(int i=1;i<=n;i++) m=max(m,f[i]);
Binary optimization nlogn
int f[N];// The length is i The last bit of the increasing subsequence of
int LIS()
{
int len=0;
f[0]=-0x3f3f3f3f;
for(int i=1;i<=n;i++)
{
int l=0,r=len;
while(l<r)// Find less than a[i] The last number of
{
int mid=l+r+1>>1;
if(f[mid]<a[i])
l=mid;
else
r=mid-1;
}
len=max(len,r+1);
f[r+1]=a[i];
}
return len;
}
2. Longest common subsequence (LCS)
//LCS o(n^2)
int f[N][N];// Before the first sequence i Letters and the first of the second sequence j A subsequence of letters Maximum common subsequence length of
边栏推荐
- Power query data format conversion, Split Merge extraction, delete duplicates, delete errors, transpose and reverse, perspective and reverse perspective
- LeetCode 1189. Maximum number of "balloons"
- devkit入门
- MIT doctoral thesis | robust and reliable intelligent system using neural symbol learning
- Synchronized and reentrantlock
- Room cannot create an SQLite connection to verify the queries
- Notepad + + regular expression replace String
- 时间戳的拓展及应用实例
- Power Query数据格式的转换、拆分合并提取、删除重复项、删除错误、转置与反转、透视和逆透视
- Date类中日期转成指定字符串出现的问题及解决方法
猜你喜欢
Go learning - dependency injection
XML配置文件
OpenCV经典100题
Model analysis of establishment time and holding time
MIT doctoral thesis | robust and reliable intelligent system using neural symbol learning
OS i/o devices and device controllers
Leetcode 450 deleting nodes in a binary search tree
Idea远程提交spark任务到yarn集群
建立时间和保持时间的模型分析
MCU realizes OTA online upgrade process through UART
随机推荐
Spark SQL null value, Nan judgment and processing
Opencv classic 100 questions
Idea远程提交spark任务到yarn集群
时间戳的拓展及应用实例
Extracting profile data from profile measurement
Leetcode 44 Wildcard matching (2022.02.13)
The value of applet containers
云导DNS和知识科普以及课堂笔记
建立时间和保持时间的模型分析
[Chongqing Guangdong education] reference materials for Zhengzhou Vocational College of finance, taxation and finance to play around the E-era
《编程之美》读书笔记
Folding and sinking sand -- weekly record of ETF
MIT博士论文 | 使用神经符号学习的鲁棒可靠智能系统
Lone brave man
The relationship between FPGA internal hardware structure and code
NLP basic task word segmentation third party Library: ICTCLAS [the third party library with the highest accuracy of Chinese word segmentation] [Chinese Academy of Sciences] [charge]
Model analysis of establishment time and holding time
OS i/o devices and device controllers
新手入门深度学习 | 3-6:优化器optimizers
Anconda download + add Tsinghua +tensorflow installation +no module named 'tensorflow' +kernelrestart: restart failed, kernel restart failed