Problem Statement
You are given a String text. Determine the letters (both lowercase and uppercase) that appear in text. Return a String which contains those letters, converted to lowercase, and then sorted in alphabetical order. The returned String should include all occurrences of each letter.
Definition
- Class:
- TextProcessor
- Method:
- collectLetters
- Parameters:
- String
- Returns:
- String
- Method signature:
- String collectLetters(String text)
- (be sure your method is public)
Constraints
- text will contain between 1 and 50 characters, inclusive.
- text will contain only letters ('A'-'Z', 'a'-'z'), digits ('0'-'9'), and spaces (' ').
Examples
"She sells sea shells"
Returns: "aeeeehhllllssssss"
The letters that appear in the input are "shesellsseashells" (converted to lower case and ignoring non-letter characters). Then we sort these letters alphabetically."ReMemBEr To IgnoRE CASe"
Returns: "abceeeeegimmnoorrrst"
"12345"
Returns: ""
There are no letters, so the empty String should be returned."TopCoder is fun"
Returns: "cdefinooprstu"
"Knights are better than Bishops"
Returns: "aabbeeeghhhiiknnoprrssstttt"