set.seed (12345)
data <- paste(sample(c("A","C","G","T"),100000,replace=TRUE,prob=rep(0.25,4)))
data <- ifelse(data=="A",1,0)
Suppose I convert the data into 1 (desired character) and 0 (else). Then take sum at each positions. If sum upto a position matches sum upto the next, we stop; otherwise we carry on the sum and store the sums at the positions. Then the maximum sum at corresponding position will give the maximum length of sequence.
I got the algorithm but can't code it. Please help.