TopcoderArchive
Archive
Algorithm problem

CompanyName

Problem statement, definition, constraints, and public examples.

Problem Statement

You are choosing the name for your company. You have several proposals, and you want to choose the easiest to remember. Thus you calculate a special remembering value for each word, and choose the word with the smallest remembering value.

You can calculate the remembering value of the word in two steps. First, you should find all maximal groups of consecutive vowels (if the word is "DoUble", "oU" and "e" are the two groups). Each such group adds 1 point to the remembering value. Second, you should find all maximal groups of consecutive consonants. Each such group adds (2*(Length of the group) - 1) points to the remembering value.

Given a list of all proposals, return the one with the smallest remembering value. In case of a tie, return the proposal which comes first in the input.

Definition

Class:
CompanyName
Method:
shortestProposal
Parameters:
String[]
Returns:
String
Method signature:
String shortestProposal(String[] proposals)
(be sure your method is public)

Notes

  • For the purposes of this problem, we are always considering 'Y' to be a consonant. The vowels are only 'A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U' and 'u'.

Constraints

  • proposals will contain between 1 and 50 elements, inclusive.
  • Each element of proposals will contain between 3 and 50 characters, inclusive.
  • Each element of proposals will contain only letters ('a'-'z' and 'A'-'Z').

Examples

  1. {"Top", "Coder", "SRM"}
    Returns: "Top"
    The remembering value of "Top" is 3, for "Coder" and "SRM" it is 5.
  2. {"SRM", "TCO", "TCCC"}
    Returns: "TCO"
  3. {"java", "CPP", "CSharp", "VBasic"}
    Returns: "java"
  4. {"aaa", "AAa", "aaA", "AAA", "AaA", "Aaa"}
    Returns: "aaa"
    The remembering value of all proposals is 1. You should return the first one.
  5. {"bIwuZFsHVQUWIABhgXYiyBmUgwSFvUfJKcGrKUb", "CbjspPBtuDwlyxNMaJBIEzVDPipR", "wGiqORBPEaKOYVwtiCmKHLkBS",
     "aBpRqKPBtxYNuGMhtXmgWxT", "sALonbrAMgOESizcTNhgBeAT", "PpnecUCIPdyyeOvZwVHygGgjthT", "jsiAzTEiBiXqgeSGd",
     "fxUtmmfbpQoYMPenNaTtKKoCYaIhwHBJePAFtvhVPDQHiLjDcr", "jIIOwgKw"}
    Returns: "jIIOwgKw"
Back to all problems