当前位置:网站首页>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];
}
};
边栏推荐
- 【论文笔记】—低照度图像增强—Supervised—RetinexNet—2018-BMVC
- Triton部署mmdeploy导出的TensorRT模型失败篇
- FCN - the originator of semantic segmentation (based on tf-Kersa reproduction code)
- CSRF和SSRF漏洞
- Lightweight Backbone VGNetG Achieves "No Choice, All" Lightweight Backbone Network
- 中断和异常的处理与抢占式多任务
- [Paper Notes] - Low Illumination Image Enhancement - Supervised - RetinexNet - 2018-BMVC
- The national vocational skills contest competition of network security emergency response
- MySQL重置root密码
- QT + msvc2017编译器
猜你喜欢
随机推荐
FCN - the originator of semantic segmentation (based on tf-Kersa reproduction code)
两日总结七
JVM工具之 JPS
MMDeploy部署实战系列【第四章】:onnx,tensorrt模型推理
MySQL基础(DDL、DML、DQL)
ThreadLocal内存泄漏问题讲解
LeetCode每日五题01:两数之和 (均1200题)
西门子PLC1200与fanuc机器人进行profibus通讯
MAML principle explanation and code implementation
【并发】概念
matlab封闭曲线拟合 (针对一些列离散点)
(19)[系统调用]SSTD hook 阻止关闭
力扣每日一题-第47天-15. 三数之和
babylon 里面加gltf 模型
ContrstrainLayout的动画之ConstraintSet
全国职业院校技能大赛网络安全竞赛之应急响应
轻量化Backbone VGNetG成就“不做选择,全都要”轻量化主干网络
Triton部署mmdeploy导出的TensorRT模型失败篇
ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)解决办法
字节跳动岗位薪酬体系曝光,看完我真的酸了...