博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
字符串匹配动态规划
阅读量:6895 次
发布时间:2019-06-27

本文共 552 字,大约阅读时间需要 1 分钟。

题目

 

思路

1. 共性: 基于最后一位是否相同来决定递归函数的走向

 

2. 第一题. dp[i][j] 表示 str1[0...i], str2[0...j] 之间的距离

  dp[i][j] = dp[i-1][j-1] if str1[i] == str2[j]

  dp[i][j] = min(dp[i-1][j], dp[i-1][j-1], dp[i][j-1]) else

 

3. 第二题. dp[i][j] 表示 str1[0...i] 能否被 str2[0...j] 和 str3[0...i-j] 表示

dp[i][j] = dp[i-1][j-1] if(str1[i] == str2[[j])

dp[i][j] = dp[i-1][j] if(str[i] == str3[i-j])

 

4. 第三题. 统计方案数.

dp[i][j] 表示 str1[0...i] 由 str2[0...j] 表示的方案数

dp[i][j] = dp[i-1][j-1] + dp[i][j-1] if(str1[i] == str2[j])

dp[i][j] = dp[i][j-1] else

 

转载于:https://www.cnblogs.com/zhouzhuo/p/3618830.html

你可能感兴趣的文章
第二、UIScrollView的使用大全
查看>>
Ehcache(03)——Ehcache中储存缓存的方式
查看>>
基于海康监控的图像识别设计
查看>>
Senparc.Weixin.MP SDK 微信公众平台开发教程(十五):消息加密
查看>>
CCNA2.0笔记_HSRP
查看>>
wamp You don't have permission to access / on this server等问题的解决.
查看>>
【POJ】3071 Football
查看>>
ArcGis 统计方法
查看>>
Resource interpreted as Script but transferred with MIME type text/plain
查看>>
VirtualBox安装及使用说明和虚拟机安装XP系统图文教程
查看>>
【android】优秀的UI资源站点集合
查看>>
iOS 容易引“起循环引用”的三种场景
查看>>
轮播图点击 手势 代码
查看>>
新年札记:自学系统补完计划
查看>>
[Javascript] Gradient Fills on the HTML5 Canvas
查看>>
对CAB文件进行数字签名
查看>>
SQL Server 变更数据捕获(CDC)
查看>>
Starting httpd:Could not reliably determine the server's fully qualified domain name
查看>>
2015第19周一
查看>>
datatables 参数详解(转)
查看>>