Longest Cipher You are working on a secret government project and are tasked with decoding. You hit upon a theory that the cipher is hidden within a sequence of characters and has the following restrictions: (a) It has to contain at least one uppercase character. (b) It cannot contain any digits. You are given a string
s
consisting of
n
alphanumerical characters. You need to find the longest substring of
s
and return its length. A substring is defined as a contiguous segment of a string. For example, given "k3Cb," the substrings that are valid ciphers are "C" and "Cb." Note that "
kCb
" is not a substring, and "k3B" is not a valid cipher. In this case, your function should return 2 as the longest substring is "Cb." Alternatively, given "k3uu," your function should return -1 since there is no substring that satisfies the restrictions on the format of a valid cipher. Input The input contains a string
s
. Output Print the length of the longest substring that is a valid cipher. If there is no such substring, your function should return
-1
. Constraints
1<=n<=200
s
consists only of alphanumerical characters and/or A-Z and/or 0-9). Example #1 Input a2Bac Output 3 Explanation: The three valid ciphers are
{B,Ba,Bac}
, so the output is the length of "Bac," which is 3. Example #2 Input aAObCbd Output 4 Explanation: The valid ciphers are ,
bCbd,Cbd
, so the output is 4 .