当前位置:网站首页>[linear DP] shortest editing distance
[linear DP] shortest editing distance
2022-07-01 02:55:00 【Nathan Qian】
subject

explain
Code segment
#include<iostream>
using namespace std;
int n,m;
const int N=1010;
char a[N],b[N];
int f[N][N];
int main()
{
cin>>n>>a+1;
cin>>m>>b+1;
for(int i=1;i<=n;i++)f[i][0]=i;
for(int i=1;i<=m;i++)f[0][i]=i;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
f[i][j]=min(f[i-1][j]+1,f[i][j-1]+1);
if(a[i]==b[j])f[i][j]=min(f[i-1][j-1],f[i][j]);
f[i][j]=min(f[i-1][j-1]+1,f[i][j]);
}
cout<<f[n][m]<<endl;
}边栏推荐
- Record a service deployment failure troubleshooting
- Communication protocol -- Classification and characteristics Introduction
- Sampling Area Lights
- Xception学习笔记
- Densenet network paper learning notes
- Use ipmitool to configure BMC network and user information of X86 server
- C language a little bit (may increase in the future)
- Detailed data governance knowledge system
- Const and the secret of pointers
- kubernetes资源对象介绍及常用命令(二)
猜你喜欢

Huawei operator level router configuration example | BGP VPLS configuration example

【小程序项目开发 -- 京东商城】uni-app 商品分类页面(下)
![[applet project development -- Jingdong Mall] classified navigation area of uni app](/img/cb/b0b79444dc90980cd2220ff9e68549.png)
[applet project development -- Jingdong Mall] classified navigation area of uni app
性能测试常见面试题

产业互联网中,「小」程序有「大」作为

【Qt】添加第三方库的知识补充

Restcloud ETL实践之数据行列转换

Restcloud ETL practice to realize incremental data synchronization without identification bit

AI edge computing platform - beaglebone AI 64 introduction

RestCloud ETL WebService数据同步到本地
随机推荐
RestCloud ETL WebService数据同步到本地
Mouse over effect 7
PHP batch Excel to word
鼠标悬停效果十
Sampling Area Lights
Communication protocol -- Classification and characteristics Introduction
Xception learning notes
Résumé des styles de développement d'applets Wechat
DenseNet网络论文学习笔记
鼠标悬停效果五
MCU firmware packaging Script Software
Multithreaded printing
【小程序项目开发--京东商城】uni-app之自定义搜索组件(上)
一文讲解发布者订阅者模式与观察者模式
ipmitool下载地址和编译安装时可能出现的问题
Contrastive learning of Class-agnostic Activation Map for Weakly Supervised Object Localization and
调试定位导航遇到的问题总结
The operation efficiency of the park is improved, and the application platform management of applet container technology is accelerated
JS anti shake and throttling
Mnasnet learning notes

