Skip to content

Commit dd8ef0c

Browse files
committed
Time: 75 ms (39.06%), Space: 169.3 MB (25.59%) - LeetHub
1 parent b0afca1 commit dd8ef0c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public:
3+
string answerString(string word, int numFriends) {
4+
int n = word.size();
5+
if (numFriends == 1) return word;
6+
int len = n - numFriends + 1;
7+
string ans;
8+
for (int i = 0; i < n; i++) {
9+
ans = max(ans, word.substr(i, len));
10+
}
11+
return ans;
12+
}
13+
};

0 commit comments

Comments
 (0)