All submissions for this problem are available.
After the defeat at the hands of Reverse Flash. The Flash needs to train more to become faster. He can gain more speed if he runs on a longer distance. There are N blocks in the Central City. The Path among the blocks in the city is represented by a String S where each character in the string 'S' represents a block of Central City.
The Flash can start at any block, runs around the city and stops only when he reaches any of the visited blocks.
To gain maximum speed the Flash has to run maximum distance. Your task is to find out the maximum distance the flash can run in the city in different blocks.
The first line contains the number of test cases 'T'.
Each test case contains a string 'S'.
For each test case print the length of maximum path.
- 1 ≤ T ≤ 10000
- 1 ≤ |S| ≤ 1000
Input: 3 xyzax hhhh xwxyzabcxr Output: 4 1 7
In test case 3, The flash can run on the following blocks to gain maximum speed.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, RUBY, PHP, SCALA, PERL, BASH, LISP sbcl, LISP clisp, PERL6|
Fetching successful submissions