File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const answerString = (word, numFriends, res = '') => {
2+
if (numFriends === 1) return word;
3+
4+
const L = word.length;
5+
6+
for (let i = 0; i < L; i++) {
7+
let str = word.substring(i, Math.min(i + L - numFriends + 1, L));
8+
if (str > res) res = str;
9+
}
10+
11+
return res;
12+
};

0 commit comments

Comments
 (0)