human
Check if all occurrences of a character appear together | function to find if all occurrences of a character appear together in a string ..
To indicate if one or more occurrences of ' c ' are seen or not ..
Traverse given string.
If current character is same as c , we first check if c is already seen ..
If this is very first appearance of c , we traverse all consecutive occurrences ..
To indicate that character is seen once ..
Driver Code"
Solution in Python:
 What is a code to check if all occurrences of a character appear together and the other steps required?
assistant
#Here is code to check if all occurrences of a character appear together and the other steps required.
 def checkIfAllTogether ( s , c ) :
	oneSeen = False
	i = 0
	n = len ( s )
	while ( i < n ) :
		if ( s [ i ] == c ) :
			if ( oneSeen == True ) :
				return False
			while ( i < n and s [ i ] == c ) :
				i = i + 1
			oneSeen = True
		else :
			i = i + 1
	return True
s = "110029" ;
if ( checkIfAllTogether ( s , '1' ) ) :
	print ( " Yes " )
else :
	print ( " No " )