TopcoderArchive
Archive
Algorithm problem

TextProcessor

Problem statement, definition, constraints, and public examples.

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

  1. "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.
  2. "ReMemBEr To IgnoRE CASe"
    Returns: "abceeeeegimmnoorrrst"
  3. "12345"
    Returns: ""
    There are no letters, so the empty String should be returned.
  4. "TopCoder is fun"
    Returns: "cdefinooprstu"
  5. "Knights are better than Bishops"
    Returns: "aabbeeeghhhiiknnoprrssstttt"
Back to all problems