Leetcode 392. 判断子序列(DAY 26)---- 动态规划学习期 双百解法
发布日期:2021-06-30 22:24:37 浏览次数:2 分类:技术文章

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

文章目录


原题题目

在这里插入图片描述



代码实现(首刷自解) 但感觉没有用到DP

bool isSubsequence(char * s, char * t){
int tpos = 0,spos = 0,lengtht = strlen(t),lengths = strlen(s); while(s[spos] && t[tpos] && lengtht >= lengths) {
if(s[spos] == t[tpos]) {
spos++; lengths--; } tpos++; lengtht--; } if(s[spos]) return false; else return true;}

代码实现(二刷C++ DAY 116)

class Solution {
public: bool isSubsequence(string s, string t) {
if(!s.size()) return true; int pos = 0,flag = 0; for(int i=0;i

转载地址:https://love6.blog.csdn.net/article/details/112836959 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Leetcode 面试题 08.01. 三步问题(DAY 26) ---- 动态规划学习期
下一篇:Leetcode 70. 爬楼梯(DAY 26) ---- 动态规划学习期

发表评论

最新留言

很好
[***.229.124.182]2024年04月06日 16时50分31秒