详见:https://leetcode.com/problems/unique-substrings-in-wraparound-string/description/

C++:

class Solution {
public:
int findSubstringInWraproundString(string p)
{
vector<int> cnt(26, 0);
int len = 0;
for (int i = 0; i < p.size(); ++i)
{
if (i > 0 && (p[i] == p[i - 1] + 1 || p[i - 1] - p[i] == 25))
{
++len;
}
else
{
len = 1;
}
cnt[p[i] - 'a'] = max(cnt[p[i] - 'a'], len);
}
return accumulate(cnt.begin(), cnt.end(), 0);
}
};

参考:https://www.cnblogs.com/grandyang/p/6143071.html

467 Unique Substrings in Wraparound String 封装字符串中的独特子字符串的更多相关文章

  1. [LeetCode] Unique Substrings in Wraparound String 封装字符串中的独特子字符串

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...

  2. 【LeetCode】467. Unique Substrings in Wraparound String 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/unique-s ...

  3. 467. Unique Substrings in Wraparound String

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...

  4. LeetCode 467. Unique Substrings in Wraparound String

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...

  5. 【LeetCode】467. Unique Substrings in Wraparound String

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...

  6. Java实现 LeetCode 467 环绕字符串中唯一的子字符串

    467. 环绕字符串中唯一的子字符串 把字符串 s 看作是"abcdefghijklmnopqrstuvwxyz"的无限环绕字符串,所以 s 看起来是这样的:"-zabc ...

  7. Leetcode 467.环绕字符串中的唯一子字符串

    环绕字符串中的唯一子字符串 把字符串 s 看作是"abcdefghijklmnopqrstuvwxyz"的无限环绕字符串,所以 s 看起来是这样的:"...zabcdef ...

  8. python判断字符串中是否包含子字符串

    python判断字符串中是否包含子字符串 s = '1234问沃尔沃434' if s.find('沃尔沃') != -1:     print('存在') else:     print('不存在' ...

  9. [Swift]LeetCode467. 环绕字符串中唯一的子字符串 | Unique Substrings in Wraparound String

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...

随机推荐

  1. Object.getOwnPropertyNames()

    1.Object.getOwnPropertyNames(),遍历实例属性(包括不可枚举),返回属性名组成的数组 var arr = ["a", "b", &q ...

  2. Ubuntu使用adb连接android手机失败unknown的解决的方法

    Ubuntu使用adb连接android手机失败unknown的解决的方法   Ubuntu下通过USB数据线连接G11手机后,adb可能无法识别到设备.依照一下步骤能够解决此问题. 1.在termi ...

  3. Mapreduce运行过程分析(基于Hadoop2.4)——(三)

    4.4 Reduce类 4.4.1 Reduce介绍 整完了Map,接下来就是Reduce了.YarnChild.main()->ReduceTask.run().ReduceTask.run方 ...

  4. [转] logback 常用配置详解(序)logback 简介

    转载文章:原文出处:http://aub.iteye.com/blog/1101222 logback 简介 Ceki Gülcü在Java日志领域世界知名.他创造了Log4J ,这个最早的Java日 ...

  5. Android之键盘监听的执行机理【看清键盘监听的本质】【入门版】

    以EditText为例: 1.Activity本身也有按键监听 editText按键监听与Activity按键监听关系: Activity本身也有按键监听 并且分按下和松开两个事件监听 editTex ...

  6. SVN下Update出现代码文件删除状态问题

    有时候在SVN上更新了代码,发觉别人提交的东西,服务上明明就是有,但本机却空空如也.只好打开 "Repo-browser",从服务器上强拉下来.结果图标显示红叉,显示为删除状态. ...

  7. envoy

    微服务意味着网络更加依赖于服务抽象边界. 随着相互依赖的服务数量日渐增长,系统100%没问题的时间会变少,整个系统经常有部分功能处于降级状态.

  8. Lightoj 1007 - Mathematically Hard

    1007 - Mathematically Hard    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 6 ...

  9. 《Visual C++ 2010入门教程》系列三:关于C++的一些问题

    <Visual C++ 2010入门教程>系列三:关于C++的一些问题   这一回我自己都不知道应该写点什么好,或许今天的篇幅会比往常短很多.我说过,这不是C++的教程,因为我还没有那个能 ...

  10. Masonry remake更新约束

    前言 说到iOS自动布局,有很多的解决办法.有的人使用xib/storyboard自动布局,也有人使用frame来适配.对于前者,笔者并不喜欢,也不支持.对于后者,更是麻烦,到处计算高度.宽度等,千万 ...