Skip to content

Commit 7725f7c

Browse files
committedJan 20, 2020
Add solution #459
1 parent 187694f commit 7725f7c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
 

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
264|[Ugly Number II](./0264-ugly-number-ii.js)|Medium|
1515
387|[First Unique Character in a String](./0387-first-unique-character-in-a-string.js)|Easy|
1616
451|[Sort Characters By Frequency](./0451-sort-characters-by-frequency.js)|Medium|
17+
459|[Repeated Substring Pattern](./0459-repeated-substring-pattern.js)|Easy|
1718
606|[Construct String from Binary Tree](./0606-construct-string-from-binary-tree.js)|Easy|
1819
617|[Merge Two Binary Trees](./0617-merge-two-binary-trees.js)|Easy|
1920
648|[Replace Words](./0648-replace-words.js)|Medium|
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* 459. Repeated Substring Pattern
3+
* https://leetcode.com/problems/repeated-substring-pattern/
4+
* Difficulty: Easy
5+
*
6+
* Given a non-empty string check if it can be constructed by taking a
7+
* substring of it and appending multiple copies of the substring
8+
* together. You may assume the given string consists of lowercase
9+
* English letters only and its length will not exceed 10000.
10+
*/
11+
12+
/**
13+
* @param {string} s
14+
* @return {boolean}
15+
*/
16+
var repeatedSubstringPattern = function(s) {
17+
return (s + s).slice(1, s.length * 2 - 1).indexOf(s) !== -1;
18+
};

0 commit comments

Comments
 (0)
Please sign in to comment.