当前位置:网站首页>LeetCode 97. 交错字符串
LeetCode 97. 交错字符串
2022-08-04 06:42:00 【HumbleFool】
const int N = 110;
class Solution {
public:
bool f[N][N] = {
false}; // 是 s1 前 i 个字符和 s2 前 j 个字符能够组成 s3 前 i+j
bool isInterleave(string s1, string s2, string s3) {
int n = s1.size(), m = s2.size();
if(n + m != s3.size()) return false;
f[0][0] = true;
for(int i = 1; i <= n; i ++)
if(s1[i - 1] != s3[i - 1])
break;
else f[i][0] = true;
for(int i = 1; i <= m; i ++)
if(s2[i - 1] != s3[i - 1])
break;
else f[0][i] = true;
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= m; j ++)
{
f[i][j] = (s1[i - 1] == s3[i + j - 1] && f[i - 1][j]) || (s2[j - 1] == s3[i + j - 1] && f[i][j - 1]); //是当前字符是s1, 或者s2
}
return f[n][m];
}
};
边栏推荐
猜你喜欢
随机推荐
误差指标分析计算之matlab实现【开源1.0.0版】
函数柯里化详解
SQL如何从字符串截取指定字符(LEFT、MID、RIGHT三大函数)
数据特征预处理——缺失值的查看方式及处理
powershell和cmd对比
使用腾讯云发送短信 ---- 手把手教你搞定所有步骤
LeetCode每日五题01:两数之和 (均1200题)
分布式计算实验3 基于PRC的书籍信息管理系统
Produce definition 产品与行业分析 勤于思考 善于总结 强于表达
Lightweight Backbone VGNetG Achieves "No Choice, All" Lightweight Backbone Network
SQL存储过程详解
[Paper Notes] - Low Illumination Image Enhancement - Supervised - RetinexNet - 2018-BMVC
matlab封闭曲线拟合 (针对一些列离散点)
错误记录:TypeError: object() takes no parameters
中职网络安全竞赛C模块MS17-010批量扫描
无人驾驶运用了什么技术,无人驾驶技术是
玩转TypeScript对象、对象作为参数进行函数传递、接口和内置对象[无敌态]
likeshop外卖点餐系统【100%开源无加密】
ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)解决办法
Centos通过Docker搭建MySQL的PXC集群






![[Paper Notes] - Low Illumination Image Enhancement - Supervised - RetinexNet - 2018-BMVC](/img/54/685fb2620aa53416437943705d3d38.png)



