IT/코딩테스트
[Leetcode] 2405. Optimal Partition of String
이주디
2024. 3. 4. 19:28
728x90
class Solution:
def partitionString(self, s: str) -> int:
substrings = []
sub = ''
for n in s:
if n in sub:
substrings.append(sub)
sub = n
else:
sub += n
substrings.append(sub)
return len(substrings)
https://leetcode.com/problems/optimal-partition-of-string
Optimal Partition of String - LeetCode
Can you solve this real interview question? Optimal Partition of String - Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
728x90