<p>Given a string <code>s</code>, partition the string into one or more <strong>substrings</strong> such that the characters in each substring are <strong>unique</strong>. That is, no letter appears in a single substring more than <strong>once</strong>.</p>

<p>Return <em>the <strong>minimum</strong> number of substrings in such a partition.</em></p>

<p>Note that each character should belong to exactly one substring in a partition.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;abacaba&quot;
<strong>Output:</strong> 4
<strong>Explanation:</strong>
Two possible partitions are (&quot;a&quot;,&quot;ba&quot;,&quot;cab&quot;,&quot;a&quot;) and (&quot;ab&quot;,&quot;a&quot;,&quot;ca&quot;,&quot;ba&quot;).
It can be shown that 4 is the minimum number of substrings needed.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;ssssss&quot;
<strong>Output:</strong> 6
<strong>Explanation:
</strong>The only valid partition is (&quot;s&quot;,&quot;s&quot;,&quot;s&quot;,&quot;s&quot;,&quot;s&quot;,&quot;s&quot;).
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
	<li><code>s</code> consists of only English lowercase letters.</li>
</ul>

class Solution:
    def partitionString(self, s: str) -> int:
        '''l = set()
        i = 0
        j = 1
        s1= ""
        s1 = s1+s[i]
        while(j<len(s)):
            
            if s[j] not in s1:
                s1 = s1+s[j]
                print(i)
                print(s1)
                l.add(s1)
                continue
            else:
                print(s1)
                i = i+1
                l.add(s[i])
                while i<len(s) and s[i] == s[i-1]:
                    i = i+1
                    l.add(s[i])
                #i = i+1
                j = i+1
                s1=""
                s1 = s1+s[i]
                l.add(s1)
                continue
            j = j+1
        print(l)
        return len(l)'''

        '''l = []
        
        i = 0
        j = 1
        s1= ""
        s1 = s1+s[i]
        while(j<len(s)):
            print(s[j])
            if s[j] not in s1:
                s1 = s1+s[j]
                j = j+1
                continue
                
            if s[j] in s1:
                l.append(s1)
                i = j+1
                j = i+1
                s1 = ""
                print("i = ",i)
                if i<len(s):
                    s1 = s1+s[i]
                    if i<len(s)-1 and s[i] == s[i+1]:
                        l.append(s1)
                else:
                    break
                continue
            j = j+1
        l.append(s1)
        print(l)
        return len(l)'''

        c = 0
        i = 0
        j = 1
        s1=set()
        s1.add(s[i])
        while(j<len(s)):
            #print(s[j])
            if s[j] not in s1:
                #print(s1)
                s1.add(s[j])
            elif s[j] in s1:
                #print(s1)
                c = c+1
                s1.clear()
                i = j
                s1.add(s[i])
                #s1 = s1 + s[i]
            #i = i+1
            j = j+1
        if s1:
            c = c+1
        #print(c)

        return c

        '''partitions = 0
        seen_chars = set()

        for char in s:
            if char in seen_chars:
                # We found a duplicate character, so we create a new partition
                partitions += 1
                seen_chars.clear()  # Clear the set for the next partition

            seen_chars.add(char)  # Add the character to the current partition

        # Count the last partition if there are remaining characters in the set
        if seen_chars:
            partitions += 1

        return partitions'''
        
138