Skip to content

Commit 0cf0f1c

Browse files
committed
Jun 04
1 parent 9055800 commit 0cf0f1c

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution:
2+
def answerString(self, word: str, numFriends: int) -> str:
3+
if numFriends == 1:
4+
# no split possible
5+
return word
6+
n = len(word)
7+
# brute force
8+
return max([word[i: i + n - (numFriends - 1)] for i in range(n)])
9+
10+
11+
def main():
12+
word = 'dbca'
13+
numFriends = 2
14+
assert Solution().answerString(word, numFriends) == 'dbc'
15+
16+
word = 'gggg'
17+
numFriends = 4
18+
assert Solution().answerString(word, numFriends) == 'g'
19+
20+
21+
if __name__ == '__main__':
22+
main()

2025-06-June-LeetCoding-Challenge/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
| June 01 | [2929. Distribute Candies Among Children II](https://leetcode.com/problems/distribute-candies-among-children-ii/) | Medium | Unsolved |
88
| June 02 | [135. Candy](https://leetcode.com/problems/candy/) | Hard | Solved |
99
| June 03 | [1298. Maximum Candies You Can Get from Boxes](https://leetcode.com/problems/maximum-candies-you-can-get-from-boxes/) | Hard | Solved |
10-
| June 04 | []() | | |
10+
| June 04 | [3403. Find the Lexicographically Largest String From the Box I](https://leetcode.com/problems/find-the-lexicographically-largest-string-from-the-box-i/) | Medium | Solved |
1111
| June 05 | []() | | |
1212
| June 06 | []() | | |
1313
| June 07 | []() | | |
@@ -40,5 +40,5 @@
4040
| Level | Problems | Solved | Unsolved |
4141
| --- | --- | --- | --- |
4242
| Easy | 0 | 0 | 0 |
43-
| Medium | 1 | 0 | 1 |
43+
| Medium | 2 | 1 | 1 |
4444
| Hard | 2 | 2 | 0 |

0 commit comments

Comments
 (0)