#K64577. Hashtag Suggestion
Hashtag Suggestion
Hashtag Suggestion
You are given a list of hashtags and a prefix string. Your task is to output all hashtags from the list that start with the given prefix. The matching hashtags should be printed in lexicographical (dictionary) order. If there are no hashtags that match the given prefix, simply output "No suggestions".
Note:
- The matching should be case sensitive; that is, '#Apple' and '#apple' are considered different.
- If multiple hashtags match, sort them using the standard lexicographical order.
- If no hashtags are provided or no hashtag starts with the prefix then output a single line containing "No suggestions".
Input Format (stdin):
- The first line contains an integer \(n\) representing the number of hashtags.
- The next \(n\) lines each contain a hashtag string.
- The last line contains the prefix string.
Output Format (stdout):
- If there is at least one hashtag that starts with the prefix, output each matching hashtag in a separate line in lexicographical order.
- If there are no matches, output a single line: "No suggestions".
Example:
Input: 5 #apple #application #appetizer #banana #berry #app</p>Output: #appetizer #apple #application
inputFormat
The input is read from standard input. The first line contains an integer \(n\), denoting the number of hashtags. The following \(n\) lines each contain a hashtag (a string). The last line contains the prefix string.
outputFormat
Output the matching hashtags in lexicographical order, one per line. If no hashtag starts with the given prefix, output a single line with the text "No suggestions".
## sample5
#apple
#application
#appetizer
#banana
#berry
#app
#appetizer
#apple
#application
</p>