<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> class Solution : <EOL> def removeElement_negative_index ( self , A , elem ) : <EOL> """<STR_LIT>""" <EOL> open_ptr = <NUM_LIT:0> <EOL> back_ptr = - <NUM_LIT:1> <EOL> while len ( A ) + back_ptr >= open_ptr : <EOL> if A [ open_ptr ] == elem : <EOL> A [ open_ptr ] , A [ back_ptr ] = A [ back_ptr ] , A [ open_ptr ] <EOL> back_ptr -= <NUM_LIT:1> <EOL> else : <EOL> open_ptr += <NUM_LIT:1> <EOL> return len ( A ) + back_ptr + <NUM_LIT:1> <EOL> def removeElement ( self , A , elem ) : <EOL> """<STR_LIT>""" <EOL> open_ptr = <NUM_LIT:0> <EOL> end_ptr = len ( A ) <EOL> while open_ptr < end_ptr : <EOL> if A [ open_ptr ] == elem : <EOL> end_ptr -= <NUM_LIT:1> <EOL> A [ open_ptr ] , A [ end_ptr ] = A [ end_ptr ] , A [ open_ptr ] <EOL> else : <EOL> open_ptr += <NUM_LIT:1> <EOL> return end_ptr <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> A = [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:4> ] <EOL> elem = <NUM_LIT:4> <EOL> solution = Solution ( ) <EOL> assert solution . removeElement ( A , elem ) == solution . removeElement_negative_index ( A , elem ) </s>
