@@ -0,0 +1,837 @@
+'''%0AGiven a sorted array, remove the duplicates in place such that each element appear only once and return the new length.%0A%0ADo not allocate extra space for another array, you must do this in place with constant memory.%0A%0AFor example,%0AGiven input array nums = %5B1,1,2%5D,%0A%0AYour function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't matter what you leave beyond the new length.%0A'''%0A%0Aclass Solution:%0A    # @param a list of integers%0A    # @return an integer%0A    def removeDuplicates(self, A):%0A        n = len(A)%0A        if n == 0: return 0%0A        if n == 1: return 1 %0A        %0A        slow = 0%0A        for fast in xrange(n):%0A            if A%5Bslow%5D == A%5Bfast%5D:%0A                continue%0A            else:%0A                slow += 1%0A                A%5Bslow%5D = A%5Bfast%5D%0A        return slow + 1%0A

Create Remove_duplicate_from_sorted_array.py