LCC '18 Contest 5 J2 - All About Alliteration

View as PDF

Submit solution

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

Author:
Problem type

After receiving a terrible grade on her report, Wandy must rewrite her finance paper. Still upset, she wants, this time, to only submit a paper with sentences that have alliteration (the first letters of each word are the same).

Can you, her programmer friend, help her once again by printing the longest sequence of words beginning with a given character?

Input Specification

The first line will be the character (either an uppercase or lowercase letter), C, that will be searched for in the string.

The second and final line will be a paragraph, P (1 \le |P| \le 10^3), including at least one word beginning with character C (either uppercase or lowercase). The paragraph will consist of words (uppercase and lowercase alphabetical characters), separated by spaces and period punctuation. It is guaranteed that there will be only one longest possible substring.

Output Specification

The longest possible substring in which all words begin with either uppercase C or lowercase character c.

Sample Input

a
All admit anger about the absolutely awful All About Alliteration.

Sample Output

absolutely awful All About Alliteration.

Explanation

Two substrings with alliteration with the letter a exist. The longest substring with all words beginning with a is admit anger about, but the longest substring with all words beginning with either lowercase a or uppercase A is absolutely awful All About Alliteration, so the output is absolutely awful All About Alliteration..


Comments

There are no comments at the moment.