leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2405.cpp (368B)


      1 class Solution {
      2   public:
      3     int partitionString(string s) {
      4         bitset<26> st;
      5         int res = 0;
      6         for (char c : s) {
      7             int n = c - 'a';
      8             if (!st[n])
      9                 st.set(n);
     10             else {
     11                 res++;
     12                 st.reset();
     13                 st.set(n);
     14             }
     15         }
     16         return res + 1;
     17     }
     18 };