human
Write me a the Python code you requested given the following:
I found an interesting problem on https://leetcode.com/problems/backspace-string-compare/:
Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.
Note that after backspacing an empty text, the text will continue empty.

Example 1:
Input: S = "ab#c", T = "ad#c"
Output: true
Explanation: Both S and T become "ac".

Example 2:
Input: S = "ab##", T = "c#d#"
Output: true
Explanation: Both S and T become "".

Example 3:
Input: S = "a##c", T = "#a#c"
Output: true
Explanation: Both S and T become "c".

Example 4:
Input: S = "a#c", T = "b"
Output: false
Explanation: S becomes "c" while T becomes "b".

Note:

1 <= S.length <= 200
1 <= T.length <= 200
S and T only contain lowercase letters and '#' characters.

Follow up:

Can you solve it in O(N) time and O(1) space?

I tried it in Python, but could not do it. Can you solve it?
assistant
#Here is the Python code you requested.

class Solution:
    def backspaceCompare(self, S: str, T: str) -> bool:
        i = len(S) - 1
        j = len(T) - 1
        
        skip_S = 0
        skip_T = 0
        
        while i >=0 or j >= 0:
            while i >=0 and (S[i] == '#' or skip_S > 0):
                if S[i] == '#':
                    skip_S += 1
                else:
                    skip_S -= 1
                i -= 1
                
            while j >=0 and (T[j] == '#' or skip_T > 0):
                if T[j] == '#':
                    skip_T += 1
                else:
                    skip_T -= 1
                j -= 1
                
            if i < 0 and j < 0:
                return True
            elif i >= 0 and j >= 0:
                if S[i] == T[j]:
                    i -= 1
                    j -= 1
                else:
                    return False
            elif i >=0 or j >=0:
                return False
        return True