human
Minimum distance between duplicates in a String | This function is used to find minimum distance between same repeating characters.
Store minimum distance between same repeating characters.
For loop to consider each element of string.
Comparison of string characters and updating the minDis value.
As this value would be least therefore break.
If minDis value is not updated that means no repeating characters.
Minimum distance is minDis - 1.
Given Input.
Function Call"
Solution in Python:
assistant
#Here is code to minimum distance between duplicates in a String and the other steps required.
 def shortestDistance ( S , N ) :
	minDis = len ( S )
	for i in range ( N ) :
		for j in range ( i + 1 , N ) :
			if ( S [ i ] == S [ j ] and ( j - i ) < minDis ) :
				minDis = j - i
				break
	if ( minDis == len ( S ) ) :
		return - 1
	else :
		return minDis - 1
S = " geeksforgeeks "
N = 13
print ( shortestDistance ( S , N ) )