From b2e76f5e0ef25cbde3e25ba497c6c77d0fe3749e Mon Sep 17 00:00:00 2001 From: wakidurrahman Date: Thu, 22 Jun 2023 11:38:51 +0900 Subject: [PATCH 1/2] update --- src/code-challenges/code-challenges-002-010.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/code-challenges/code-challenges-002-010.js b/src/code-challenges/code-challenges-002-010.js index d6997a6..86f7525 100644 --- a/src/code-challenges/code-challenges-002-010.js +++ b/src/code-challenges/code-challenges-002-010.js @@ -180,3 +180,9 @@ exports.iterative = function (array) { return result; }; + +/** + * Q007: Sum of Array Plus One + * + + */ From 04d22ac7cf09ca39079fdb9730ffb6f4799629bd Mon Sep 17 00:00:00 2001 From: wakidurrahman Date: Fri, 23 Jun 2023 16:28:34 +0900 Subject: [PATCH 2/2] feat: added --- src/code-challenges/code-challenges-002-010.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/code-challenges/code-challenges-002-010.js b/src/code-challenges/code-challenges-002-010.js index 86f7525..9dc1867 100644 --- a/src/code-challenges/code-challenges-002-010.js +++ b/src/code-challenges/code-challenges-002-010.js @@ -182,7 +182,14 @@ exports.iterative = function (array) { }; /** - * Q007: Sum of Array Plus One - * - + * Q008: String Rotation + * Problem: Find out if a string is a rotation of another string. + * E.g. 'ABCD' is a rotation of 'BCDA' but not 'ACBD' */ + +// First make sure 'a' and 'b' are of the same length. +// Then check to see if 'b' is a substring of 'a' concatenated with 'a' + +module.exports = function (a, b) { + return a.length === b.length && (a + a).indexOf(b) > -1; +};