LeetCode 1668. Maximum Repeating Substring 环球聚焦
2023-05-11 08:54:18 哔哩哔哩

For a string sequence, a string wordis k-repeating if wordconcatenated ktimes is a substring of sequence. The word's maximum k-repeating value is the highest value kwhere wordis k-repeating in sequence. If wordis not a substring of sequenceword's maximum k-repeating value is 0.

Given strings sequenceand word, return the maximum k-repeating value of wordin sequence.


(资料图片仅供参考)

Example 1:

Input: sequence = "ababc", word = "ab"

Output: 2

Explanation: "abab" is a substring in "ababc".

Example 2:

Input: sequence = "ababc", word = "ba"

Output: 1

Explanation: "ba" is a substring in "ababc". "baba" is not a substring in "ababc".

Example 3:

Input: sequence = "ababc", word = "ac"

Output: 0

Explanation: "ac" is not a substring in "ababc".

Constraints:

1 <= sequence.length <= 100

1 <= word.length <= 100

sequenceand wordcontains only lowercase English letters.

easy题目,依次遍历即可;

下面是代码:

Runtime: 0 ms, faster than 100.00% of Java online submissions for Maximum Repeating Substring.

Memory Usage: 40.9 MB, less than 50.11% of Java online submissions for Maximum Repeating Substring.

热门推荐

文章排行

  1. 2023-05-11LeetCode 1668. Maximum Repeating Substring 环球聚焦
  2. 2023-05-11是什么导致壁炉指示灯不断熄灭?_适合送给初中女生礼物有哪些
  3. 2023-05-11高德打车的特价车是什么意思_特价车是什么意思
  4. 2023-05-1153岁战神巴蒂现身!须发全白在庄园养老,养2匹马+20岁小儿子接班 快播
  5. 2023-05-11天天新消息丨聚焦重点靶向发力 万亿税费红利加快释放
  6. 2023-05-11测天通地全线护航,“快递小哥”使命必达
  7. 2023-05-11绝色师兄缠不休作者:尊克星 绝色师兄缠不休
  8. 2023-05-10萨迈拉大清真寺_SAMA
  9. 2023-05-10《羊了个羊》回应游戏被工信部通报:第三方平台广告组件出问题 环球新要闻
  10. 2023-05-10荣盛石化:子公司年产25万吨功能性聚酯薄膜扩建项目投产
  11. 2023-05-10当日快讯:瑞士政府:俄罗斯央行有近74亿瑞郎资产位于瑞士,已无法动用
  12. 2023-05-10每日热点:张小泉再谈菜刀断裂:有三种可能
  13. 2023-05-10世界微资讯!女性骑自行车减肥有什么好处?
  14. 2023-05-10力尊信通每10股派现5元 共计派发现金红利2227.98万元_世界热点评
  15. 2023-05-10最新法案!纽约州将终止各大学本科提前录取政策!-焦点热讯
  16. 2023-05-10环球热点评!视觉中国涨停
  17. 2023-05-10关注糖尿病蝴蝶效应 器官0伤害从你我做起
  18. 2023-05-10美好社区需要哪些项目?新泾镇这场评审会有看头!_世界新消息
  19. 2023-05-10告别“3时代”!多家银行宣布“下调”人民币存款利率
  20. 2023-05-10AWS刚刚公布了一系列安全升级以确保您的云系统安全 当前动态