0
点赞
收藏
分享

微信扫一扫

87 GB 模型种子,GPT-4 缩小版,超越ChatGPT3.5,多平台在线体验

2023每日刷题(六十)

Leetcode—2414.最长的字母序连续子字符串的长度

在这里插入图片描述

实现代码

class Solution {
public:
    int longestContinuousSubstring(string s) {
        int ans = 1;
        int t = 1;
        for(int i = 1; i < s.size(); i++) {
            if(s[i] - s[i - 1] == 1) {
                t++;
                ans = max(ans, t);
            } else {
                t = 1;
            }
        }
        return ans;
    }
};

运行结果

在这里插入图片描述
之后我会持续更新,如果喜欢我的文章,请记得一键三连哦,点赞关注收藏,你的每一个赞每一份关注每一次收藏都将是我前进路上的无限动力 !!!↖(▔▽▔)↗感谢支持!

举报

相关推荐

0 条评论