Trying to find longest Uniform Substring.
Suppose I have abbbccda then We have to get the index position of "bbb " ie. [1, 3] So it should return [1, 3] . Because Uniform Substring starts from index 1 and is 3 characters long.
Other Example:
"10000111" => [ 1, 4 ]
"aabbbbbCdAA" => [ 2, 5 ]
What is the python code to solve this
MY code is so long any short Way. Ignore the print there are so many to see the output
x="aaaabbbbCdAA"
LIST1=[]
for char in x:
if(char not in LIST1 ):
LIST1.append(char)
print(LIST1)
list1=[]
for i in LIST1:
list1.append(x.count(i))
print(list1)
Max_length_Charcater= max(list1)
print(Max_length_Charcater)
index_Max_length_Charcater=list1.index(Max_length_Charcater)
print(index_Max_length_Charcater)
y=LIST1[index_Max_length_Charcater]
print(y)
l=index_Max_length_Charcater
start_of_max_length_character=x.find(y)
for i in range(len(x)):
if(x[i]==y):
l+=1
print(l)
print("({0},{1})" .format(start_of_max_length_character,l))