def removeElement_negative_index(self, A, elem):
        """
        Constant space
        Algorithms: Two Pointers
        Partitioning the array into 3 parts, closed, open, back
        Data structure: array
        :param A: list
        :param elem: integer
        :return: "shrunk" list
        """

        open_ptr = 0
        back_ptr = -1  # Python style backward
        while len(A)+back_ptr>=open_ptr:
            if A[open_ptr]==elem:
                A[open_ptr], A[back_ptr] = A[back_ptr], A[open_ptr]
                back_ptr -= 1
            else:
                open_ptr += 1

        return len(A)+back_ptr+1  # length is index+1
dataset/ETHPy150Open algorhythms/LeetCode/025 Remove Element.py/Solution.removeElement_negative_index/original