human
Last duplicate element in a sorted array | Python3 code to print last duplicate element and its index in a sorted array.
if array is null or size is less than equal to 0 return.
compare elements and return last duplicate and its index.
If we reach here , then no duplicate found ..
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to last duplicate element in a sorted array and the other steps required.
 def dupLastIndex ( arr , n ) :
	if ( arr == None or n <= 0 ) :
		return
	for i in range ( n - 1 , 0 , - 1 ) :
		if ( arr [ i ] == arr [ i - 1 ] ) :
			print ( " Last ▁ index : " , i ,   " Last " , ▁ " duplicate item : " , arr [ i ] )
			return
	print ( " no ▁ duplicate ▁ found " )
arr = [ 1 , 5 , 5 , 6 , 6 , 7 , 9 ]
n = len ( arr )
dupLastIndex ( arr , n )