LeetCode 76: Minimum Window Substring - Python
I'm not sure if online courses even go into this, but this is the exact opposite of what good code should look like. Unless there is a dire performance requirement (which is rarer than you think) the aim is always to make your code as readable (clear/stupid/simple) as possible, so that:

Errors have fewer places to hide
It is easier to reason about what the code is doing without going into how, which in turn helps you uncover errors, and makes it easier to change.

The most important factor in readability is intent. If you can't tell what the programmer is trying to accomplish, or how they are going about it, it will be very difficult to detect bugs.
So the real focus should be on making it clear from your code what your intention is, preferably baked into the code itself (structure, variable names etc...) and failing that, add comments.
This means you first need to decide on your overall strategy, so in this case: how are you going to find this window? There are many options, here are some:

Are you going to first get all possible windows and try each of them?
Are you going to try all windows at position 0, then move to position 1 etc...?
Are you going to try all windows of smallest size, then next size etc...?

In your code, I am really not sure what you're going for. Both are also big functions with a lot of variables. So I didn't even try to figure out what it does (and it would be the same in a professional code review: if I don't understand at a glance what the code is even trying to do, it gets rejected).
I'll go with that last option to give you an idea of how I would write code which makes the intention clear. You'll note that by forcing the code to clearly show its intention you also end up having to break things into smaller parts, and use clear variable names, and all of these things help.
Ps: you don't need to define a class in python ;-)
def find_window(base_string, target):
    &quot;&quot;&quot;
    Try all windows in ascending size order, left to right.
    &quot;&quot;&quot;
    base_string_length = len(base_string)

    def all_chars_in_window(window):
        for c in target:
            if c not in window:
                return False
        return True

    def find_match_at_size(try_length):
        end = try_length
        start = 0
        while end &lt;= base_string_length:
            window = base_string[start:end]
            if all_chars_in_window(window):
                return window
            start += 1
            end += 1

    try_length = len(target)
    while (try_length &lt;= base_string_length):
        window_found = find_match_at_size(try_length)
        if window_found:
            return window_found
        try_length += 1
    return ''

base_string = &quot;ADOBECODEBANC&quot;
target = &quot;ABC&quot;
expected = &quot;BANC&quot;

print(find_window(base_string, target))

This took 7 minutes to write, because I only had to write simple code: each bit only has a couple of variables and does something very simple. If I had forced myself to do it the way you did with all those variables and calculations, I would have been at it much longer.
Hope this helps.