LCC '18 Contest 5 S1 - QWERTY

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Prim is a programmer who loves finding ways to become more productive. Recently, she has discovered that when typing on her keyboard, she is able to type words entirely with her left hand. When this happens, she is able to use the mouse with her right hand which greatly speeds up her workflow.

Prim has asked for your help to look at the list of phrases she most commonly types and identify the longest stretch of letters that she can type entirely with her left hand. Prim can type a letter with her left hand if it appears left of the characters 'T', 'G', 'B', inclusive, on her QWERTY keyboard.

Input Specification

The first line of input contains an integer N (1 \le N \le 100,000), the number of characters in a phrase that Prim would like to you analyze. The next line contains a string with N upper-case letters, the phrase that Prim would like you to analyze.

For 40 of the 100 points, N \le 1,000.

Output Specification

Output the length of the longest segment of the phrase that Prim can type with her left hand.

Sample Input 1

10
HELLOWORLD

Sample Output 1

1

Sample Input 2

30
STEWARDSATASECRETSTARCRAFTFEST

Sample Output 2

30

Comments

There are no comments at the moment.