当前位置:网站首页>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 边栏推荐
- XML配置文件
- MCU realizes OTA online upgrade process through UART
- 小程序技术优势与产业互联网相结合的分析
- Room cannot create an SQLite connection to verify the queries
- 常用API类及异常体系
- 多线程与高并发(8)—— 从CountDownLatch总结AQS共享锁(三周年打卡)
- MCU通过UART实现OTA在线升级流程
- [groovy] compile time meta programming (compile time method interception | method interception in myasttransformation visit method)
- Leetcode Fibonacci sequence
- Spark SQL UDF function
猜你喜欢

Leetcode 450 deleting nodes in a binary search tree

Ffmpeg captures RTSP images for image analysis

建立时间和保持时间的模型分析

Introduction of motor

Room cannot create an SQLite connection to verify the queries

Comment faire votre propre robot

《强化学习周刊》第52期:Depth-CUPRL、DistSPECTRL & Double Deep Q-Network

KDD 2022 | 脑电AI助力癫痫疾病诊断

esxi的安装和使用

Opencv classic 100 questions
随机推荐
《强化学习周刊》第52期:Depth-CUPRL、DistSPECTRL & Double Deep Q-Network
如何制作自己的机器人
FFmpeg抓取RTSP图像进行图像分析
[Chongqing Guangdong education] Chongqing Engineering Vocational and Technical College
LeetCode 1189. Maximum number of "balloons"
Common API classes and exception systems
Leetcode:20220213 week race (less bugs, top 10% 555)
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]
notepad++正則錶達式替換字符串
MIT doctoral thesis | robust and reliable intelligent system using neural symbol learning
Promise
Atcoder beginer contest 258 [competition record]
Cloud guide DNS, knowledge popularization and classroom notes
Novice entry depth learning | 3-6: optimizer optimizers
Pointer pointer array, array pointer
LeetCode 斐波那契序列
孤勇者
Data analysis thinking analysis methods and business knowledge - analysis methods (III)
Classical concurrency problem: the dining problem of philosophers
[groovy] compile time meta programming (AST syntax tree conversion with annotations | define annotations and use groovyasttransformationclass to indicate ast conversion interface | ast conversion inte