# Optimal Partition of String (Leetcode 2405)

Problem Link: <https://leetcode.com/contest/weekly-contest-310/problems/optimal-partition-of-string/>

```python
class Solution:
    def partitionString(self, s: str) -> int:
        
        d={}
        j=0
        c=0
        n=len(s)
        for i in range(n):
            if(s[i] not in d):
                d[s[i]]=1
            else:
                c+=1
                d={}
                d[s[i]]=1
        return c+1
```
