#!/bin/python3

import sys

def main(argv):
	# Assume unsorted
	testcase_1 = [1,2,0,0,0,0,3,5]


	# Assume sorted(then we can swap element by element)
	testcase_2 = [1,1,3,6,7,8,9,9,9]

	testcase_3 = [1,1, 2,2,2,5,5,6]

	testcase_4 = [2,4,6,8,9,10]
	testcase = testcase_3
	remDuplicatesIfSorted(testcase)

	print("Result: " + str(testcase))

def exchangeTillEnd(a,start):
	
	for i in range(start, len(a)-1):
		a[i], a[i+1] = a[i+1], 0

def remDuplicatesIfSorted(a):

	for i in reversed(range(0,len(a)-1)):
		if a[i]==a[i-1]:
			exchangeTillEnd(a, i)

#LEft shift an array p spots
def left_shift(p, a):

	for i in range (p, len(a)-1):

		a[i] = a[i+1]
	
	a[len(a) -1] = 0	

## This is O(1) in space, O(n-squared) in time because of left shift requires array to move elems
def remDuplicates(a):
	
	print ("Running remove duplicates problem..")
	
	last_read = a[0]
	p = 1
	end = len(a)
	while (p<end):
		
		if (last_read == a[p]):
			left_shift(p, a)
			end -=1
		else:
			
			last_read = a[p]
			p+=1

if __name__ == "__main__":main(sys.argv[0:])

e242d7cb5bf0b525943bb0c8a164212529038018
<mask token>


def main(argv):
    testcase_1 = [1, 2, 0, 0, 0, 0, 3, 5]
    testcase_2 = [1, 1, 3, 6, 7, 8, 9, 9, 9]
    testcase_3 = [1, 1, 2, 2, 2, 5, 5, 6]
    testcase_4 = [2, 4, 6, 8, 9, 10]
    testcase = testcase_3
    remDuplicatesIfSorted(testcase)
    print('Result: ' + str(testcase))


def exchangeTillEnd(a, start):
    for i in range(start, len(a) - 1):
        a[i], a[i + 1] = a[i + 1], 0


<mask token>


def left_shift(p, a):
    for i in range(p, len(a) - 1):
        a[i] = a[i + 1]
    a[len(a) - 1] = 0


def remDuplicates(a):
    print('Running remove duplicates problem..')
    last_read = a[0]
    p = 1
    end = len(a)
    while p < end:
        if last_read == a[p]:
            left_shift(p, a)
            end -= 1
        else:
            last_read = a[p]
            p += 1


<mask token>

<mask token>


def main(argv):
    testcase_1 = [1, 2, 0, 0, 0, 0, 3, 5]
    testcase_2 = [1, 1, 3, 6, 7, 8, 9, 9, 9]
    testcase_3 = [1, 1, 2, 2, 2, 5, 5, 6]
    testcase_4 = [2, 4, 6, 8, 9, 10]
    testcase = testcase_3
    remDuplicatesIfSorted(testcase)
    print('Result: ' + str(testcase))


def exchangeTillEnd(a, start):
    for i in range(start, len(a) - 1):
        a[i], a[i + 1] = a[i + 1], 0


def remDuplicatesIfSorted(a):
    for i in reversed(range(0, len(a) - 1)):
        if a[i] == a[i - 1]:
            exchangeTillEnd(a, i)


def left_shift(p, a):
    for i in range(p, len(a) - 1):
        a[i] = a[i + 1]
    a[len(a) - 1] = 0


def remDuplicates(a):
    print('Running remove duplicates problem..')
    last_read = a[0]
    p = 1
    end = len(a)
    while p < end:
        if last_read == a[p]:
            left_shift(p, a)
            end -= 1
        else:
            last_read = a[p]
            p += 1


<mask token>

<mask token>


def main(argv):
    testcase_1 = [1, 2, 0, 0, 0, 0, 3, 5]
    testcase_2 = [1, 1, 3, 6, 7, 8, 9, 9, 9]
    testcase_3 = [1, 1, 2, 2, 2, 5, 5, 6]
    testcase_4 = [2, 4, 6, 8, 9, 10]
    testcase = testcase_3
    remDuplicatesIfSorted(testcase)
    print('Result: ' + str(testcase))


def exchangeTillEnd(a, start):
    for i in range(start, len(a) - 1):
        a[i], a[i + 1] = a[i + 1], 0


def remDuplicatesIfSorted(a):
    for i in reversed(range(0, len(a) - 1)):
        if a[i] == a[i - 1]:
            exchangeTillEnd(a, i)


def left_shift(p, a):
    for i in range(p, len(a) - 1):
        a[i] = a[i + 1]
    a[len(a) - 1] = 0


def remDuplicates(a):
    print('Running remove duplicates problem..')
    last_read = a[0]
    p = 1
    end = len(a)
    while p < end:
        if last_read == a[p]:
            left_shift(p, a)
            end -= 1
        else:
            last_read = a[p]
            p += 1


if __name__ == '__main__':
    main(sys.argv[0:])

import sys


def main(argv):
    testcase_1 = [1, 2, 0, 0, 0, 0, 3, 5]
    testcase_2 = [1, 1, 3, 6, 7, 8, 9, 9, 9]
    testcase_3 = [1, 1, 2, 2, 2, 5, 5, 6]
    testcase_4 = [2, 4, 6, 8, 9, 10]
    testcase = testcase_3
    remDuplicatesIfSorted(testcase)
    print('Result: ' + str(testcase))


def exchangeTillEnd(a, start):
    for i in range(start, len(a) - 1):
        a[i], a[i + 1] = a[i + 1], 0


def remDuplicatesIfSorted(a):
    for i in reversed(range(0, len(a) - 1)):
        if a[i] == a[i - 1]:
            exchangeTillEnd(a, i)


def left_shift(p, a):
    for i in range(p, len(a) - 1):
        a[i] = a[i + 1]
    a[len(a) - 1] = 0


def remDuplicates(a):
    print('Running remove duplicates problem..')
    last_read = a[0]
    p = 1
    end = len(a)
    while p < end:
        if last_read == a[p]:
            left_shift(p, a)
            end -= 1
        else:
            last_read = a[p]
            p += 1


if __name__ == '__main__':
    main(sys.argv[0:])

#!/bin/python3

import sys

def main(argv):
	# Assume unsorted
	testcase_1 = [1,2,0,0,0,0,3,5]


	# Assume sorted(then we can swap element by element)
	testcase_2 = [1,1,3,6,7,8,9,9,9]

	testcase_3 = [1,1, 2,2,2,5,5,6]

	testcase_4 = [2,4,6,8,9,10]
	testcase = testcase_3
	remDuplicatesIfSorted(testcase)

	print("Result: " + str(testcase))

def exchangeTillEnd(a,start):
	
	for i in range(start, len(a)-1):
		a[i], a[i+1] = a[i+1], 0

def remDuplicatesIfSorted(a):

	for i in reversed(range(0,len(a)-1)):
		if a[i]==a[i-1]:
			exchangeTillEnd(a, i)

#LEft shift an array p spots
def left_shift(p, a):

	for i in range (p, len(a)-1):

		a[i] = a[i+1]
	
	a[len(a) -1] = 0	

## This is O(1) in space, O(n-squared) in time because of left shift requires array to move elems
def remDuplicates(a):
	
	print ("Running remove duplicates problem..")
	
	last_read = a[0]
	p = 1
	end = len(a)
	while (p<end):
		
		if (last_read == a[p]):
			left_shift(p, a)
			end -=1
		else:
			
			last_read = a[p]
			p+=1

if __name__ == "__main__":main(sys.argv[0:])
