国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

459. Repeated Substring Pattern

2019-11-06 06:40:31
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not exceed 10000.Example 1:Input: "abab"Output: TrueExplanation: It's the substring "ab" twice.Example 2:Input: "aba"Output: FalseExample 3:Input: "abcabcabcabc"Output: TrueExplanation: It's the substring "abc" four times. (And the substring "abcabc" twice.)class Solution {public: bool repeatedSubstringPattern(string s) { const int len = s.length(); for(int i=1; i<=len/2; ++i){ string tmp = s.substr(0, i); int start = i; while(s.substr(start, i) == tmp && start+i <= len) start += i; if(start == len) return true; } return false; }};
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 新田县| 永泰县| 新余市| 驻马店市| 桃园县| 沧州市| 义马市| 常德市| 横峰县| 溧水县| 西城区| 遵义县| 桐柏县| 东方市| 濉溪县| 长治市| 塔河县| 启东市| 华宁县| 安乡县| 威信县| 新建县| 永济市| 安泽县| 长治县| 班玛县| 巴东县| 宣汉县| 虹口区| 沈丘县| 鄯善县| 阿勒泰市| 垦利县| 临泉县| 宁夏| 绵竹市| 竹北市| 台江县| 河池市| 邯郸市| 新安县|