human
Count of only repeated element in a sorted array of consecutive elements | Assumptions : vector a is sorted , max - difference of two adjacent elements is 1.
if a [ m ] = m + a [ 0 ] , there is no repeating character in [ s . . m ].
if a [ m ] < m + a [ 0 ] , there is a repeating character in [ s . . m ].
Driver code"
Solution in Python:
assistant
#Here is code to count of only repeated element in a sorted array of consecutive elements and the other steps required.
 def sequence ( a ) :
	if ( len ( a ) == 0 ) :
		return [ 0 , 0 ]
	s = 0
	e = len ( a ) - 1
	while ( s < e ) :
		m = ( s + e ) // 2
		if ( a [ m ] >= m + a [ 0 ] ) :
			s = m + 1
		else :
			e = m
	return [ a [ s ] , len ( a ) - ( a [ len ( a ) - 1 ] - a [ 0 ] ) ]
p = sequence ( [ 1 , 2 , 3 , 4 , 4 , 4 , 5 , 6 ] )
print ( " Repeated ▁ element ▁ is " , p [ 0 ] , " , ▁ it ▁ appears " , p [ 1 ] , " times " )