当前位置:网站首页>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 边栏推荐
- Calculate sha256 value of data or file based on crypto++
- notepad++正則錶達式替換字符串
- Browser reflow and redraw
- Uniapp development, packaged as H5 and deployed to the server
- Synchronized and reentrantlock
- 【线上小工具】开发过程中会用到的线上小工具合集
- Common API classes and exception systems
- MIT博士论文 | 使用神经符号学习的鲁棒可靠智能系统
- 数据分析思维分析方法和业务知识——分析方法(三)
- STM32 key chattering elimination - entry state machine thinking
猜你喜欢

How to make your own robot

Spark SQL null value, Nan judgment and processing

Uniapp development, packaged as H5 and deployed to the server

Extension and application of timestamp

Arduino六足机器人

MYSQL GROUP_ The concat function realizes the content merging of the same ID

LeetCode 1598. Folder operation log collector
![[groovy] JSON serialization (jsonbuilder builder | generates JSON string with root node name | generates JSON string without root node name)](/img/dd/bffe27b04d830d70f30df95a82b3d2.jpg)
[groovy] JSON serialization (jsonbuilder builder | generates JSON string with root node name | generates JSON string without root node name)

SAP Spartacus home 页面读取 product 数据的请求的 population 逻辑

Multithreading and high concurrency (8) -- summarize AQS shared lock from countdownlatch (punch in for the third anniversary)
随机推荐
MySQL storage engine
Spark DF adds a column
Classic CTF topic about FTP protocol
Cloud guide DNS, knowledge popularization and classroom notes
Solve the problem of reading Chinese garbled code in sqlserver connection database
小程序技术优势与产业互联网相结合的分析
Intensive learning weekly, issue 52: depth cuprl, distspectrl & double deep q-network
Power Query数据格式的转换、拆分合并提取、删除重复项、删除错误、转置与反转、透视和逆透视
Uniapp development, packaged as H5 and deployed to the server
《编程之美》读书笔记
LeetCode 8. String conversion integer (ATOI)
Start from the bottom structure and learn the introduction of fpga---fifo IP core and its key parameters
Atcoder beginer contest 254 [VP record]
Go learning --- read INI file
Location based mobile terminal network video exploration app system documents + foreign language translation and original text + guidance records (8 weeks) + PPT + review + project source code
Multithreading and high concurrency (8) -- summarize AQS shared lock from countdownlatch (punch in for the third anniversary)
Browser reflow and redraw
免费的聊天机器人API
A preliminary study of geojson
孤勇者