VALENTINE DAY GIFT 2K18
All submissions for this problem are available.
Valentine Day Gift
On Valentine day chef wants to make her fiancee Amelia happy by giving a gift to her.Amelia likes necklace of pearls a lot.So, the chef has decided to make a necklace for her fiancee.The chef is busy in making arrangements for Valentine's eve.So chef has asked for your help.Chef has given you a string of length L which contains five different types of pearls 'a', 'b', 'c', 'd', 'e'.Your task is to make a necklace of maximum possible length from the given string S which starts and end with the same type of pearls.
Help chef finding such a necklace form the given string and make his Valentine day special.
- The first line of the input contains an integer T denoting the number of test cases
- Next T line contains String S.
- For each test case, output a single line containing one single integer denoting the length of necklace.
- 1 ≤ T ≤ 20
- 1 ≤ L ≤ 10000
Input: 2 cabcadbae cdeabe Output: 7 4
Example case 1.
From the given string, we get the necklace 'abcadba' which has continuous maximum possible length 7 and also starting pearl is of same type as last pearl.
|Tags||easy, mehul_dholiya, mehul_dholiya|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS|
Fetching successful submissions