#K95267. Longest Contiguous Character Segment

    ID: 38826 Type: Default 1000ms 256MiB

Longest Contiguous Character Segment

Longest Contiguous Character Segment

Given a DNA sequence of length (n) and a specific character, write a program to determine the length of the longest contiguous segment where the given character appears. Formally, if the DNA sequence is represented as a string (S) and the character as (c), you need to find the maximum value of the consecutive occurrences of (c). That is, compute $$\max_{1 \leq i \leq n} {\text{length of consecutive } c \text{ starting at index } i}.$$

For example, if the input is (n = 10), (S = \texttt{ACGTACGTAA}), and (c = \texttt{A}), the correct answer is 2 because the longest contiguous segment of 'A' has length 2.

inputFormat

The input is read from standard input (stdin) and consists of three lines:
1. The first line contains an integer (n), representing the length of the DNA sequence.
2. The second line contains a string (S), the DNA sequence.
3. The third line contains a single character (c), for which the longest contiguous segment must be computed.

outputFormat

Output a single integer to standard output (stdout) representing the length of the longest contiguous segment of the character (c) in the DNA sequence.## sample

1
A
A
1