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

首頁 > 學院 > 開發設計 > 正文

459. Repeated Substring Pattern

2019-11-08 19:31:33
字體:
來源:轉載
供稿:網友

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: False

Example 3:

Input: "abcabcabcabc"Output: TrueExplanation: It's the substring "abc" four times. (And the substring "abcabc" twice.)class Solution {public: bool repeatedSubstringPattern(string str) { int len = str.length(), i, j; for(i = 1; i <= len / 2; i++){ if(len % i == 0){ string mode = str.substr(0, i); for(j = i; j < len; j += i){ string tmp = str.substr(j, i); if(tmp != mode) break; } if(j == len) return true; } } return false; }};
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沅陵县| 龙泉市| 张北县| 邹城市| 突泉县| 武定县| 成安县| 阳曲县| 龙山县| 临桂县| 孟连| 临泉县| 新乐市| 饶河县| 中江县| 渝中区| 台江县| 北流市| 达州市| 绥滨县| 防城港市| 大丰市| 临邑县| 正宁县| 汉中市| 兴化市| 松溪县| 凤山县| 凯里市| 安达市| 佛学| 曲松县| 栾城县| 博乐市| 西乡县| 乌审旗| 从江县| 蓝田县| 吉水县| 任丘市| 饶阳县|