TopcoderArchive
SRM22 Aug 2005
SRM 259

SuperString

Problem statement, definition, constraints, and public examples.

Problem Statement

We define the goodness of a string S as the number of letters that appear in S only once. For instance, the goodness of the string "CHALLENGE" is 5 because it contains 5 distinct letters 'C', 'H', 'A', 'N' and 'G'.

You are given a String[] superstring. superstring is split for convenience only, so you should concatenate all of its elements in order and treat it as a single string. You are to find the substring of superstring that has the maximal goodness. In case of a tie, return the substring that comes earliest alphabetically.

Definition

Class:
SuperString
Method:
goodnessSubstring
Parameters:
String[]
Returns:
String
Method signature:
String goodnessSubstring(String[] superstring)
(be sure your method is public)

Constraints

  • superstring will have between 1 and 50 elements, inclusive.
  • Each element of superstring will contain between 1 and 50 characters, inclusive.
  • Each element of superstring will contain uppercase letters ('A'-'Z') only.

Examples

  1. {"CHALLENGE"}
    Returns: "CHALLENG"
  2. {"THEWORD"}
    Returns: "THEWORD"
  3. {"THE", "MULTI", "LINE", "TEST"}
    Returns: "HEMULTI"
  4. {"ZYXWVUTSRQPONMLKJIHGFEDCBA", "ZYXWVUTSRQPONMLKJIHGFEDCBA"}
    Returns: "AZYXWVUTSRQPONMLKJIHGFEDCB"
Back to all problems