def get_longest(self, S, p, q, i, j):
        start_i = i
        start_j = j
        local_max = 0
        n = len(p)
        cur_diff = 0
        while i < n and j < n:
            if p[i] != q[j]:
                cur_diff += 1

            if cur_diff > S:  # then shrink the left side of window
                while p[start_i] == q[start_j]:
                    start_i += 1
                    start_j += 1
                start_i += 1
                start_j += 1
                cur_diff -= 1

            local_max = max(local_max, i - start_i + 1)

            i += 1
            j += 1

        return local_max
dataset/ETHPy150Open algorhythms/HackerRankAlgorithms/Substring Diff.py/Solution.get_longest/original