LeetCode 76: Minimum Window Substring
In the following code, I tried two modifications.

I slightly modified the way tests are performed, in order to minimize them a little bit

I used iterators, like this :auto p_str = base_string.begin() + right;


with the idea to avoid a redirection here:
count_map[*p_str++]--;

instead of
count_map[base_string[right++]]--;

At the end, we cannot be sure how much the speed has been improved. A benchmark is needed (by LeetCode?). We can only be sure that the code is more difficult to read!
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &lt;cassert&gt;


std::string minWindow(std::string base_string, std::string target) {
    std::vector&lt;int&gt; count_map(128, 0);
    int n = base_string.length();

    for (auto character : target)
        count_map[character]++;

    int left = 0, right = 0;
    int min_left = 0, min_right = n+1;
    int target_length = target.size();

    while (right &lt; n) {
        auto p_str = base_string.begin() + right;
        while (target_length &gt; 0 &amp;&amp; p_str != base_string.end()) {
            if (count_map[*p_str++]-- &gt; 0)
                target_length--;
        }
        right = p_str - base_string.begin();
        
        if (target_length == 0 &amp;&amp; right - left &lt; min_right)
                min_right = right - left;

        p_str = base_string.begin() + left;
        while (target_length == 0) {
            if (count_map[*p_str++]++ == 0) {
                left = p_str - base_string.begin() - 1;
                if (right - left &lt; min_right)
                    min_right = right - (min_left = left);
                target_length++;
            }
        }
        left = p_str - base_string.begin();
    }
    if (target_length == 0 &amp;&amp; (right - left &lt; min_right))
        min_right = right - (min_left = left);
            
    return min_right == n ? &quot;&quot; : base_string.substr(min_left, min_right);
}


int main() {
    std::string s = &quot;XXXABYYCTTTABYC&quot;;
    std::string target = &quot;CBA&quot;;
    std::cout &lt;&lt; minWindow (s, target) &lt;&lt; &quot;\n&quot;;
    
}