TopcoderArchive
Archive
Algorithm problem

BillboardAdvertisement

Problem statement, definition, constraints, and public examples.

Problem Statement

A company decided to place its advertisement on a big billboard. In order to make the advertisement more noticeable some letters in the company name will be uppercase. Market research shows that the profit obtained by making a letter 'a' uppercase is equal to 1. The profit obtained by making a letter 'b' uppercase is equal to 2, and so on. A federal advertising law forbids using three or more uppercase letters in a row. It also forbids using 4 or more uppercase letters in any 7 consecutive letters.

Given a String companyName, return the maximal possible profit obtained by making some of the letters uppercase.

Definition

Class:
BillboardAdvertisement
Method:
maxProfit
Parameters:
String
Returns:
int
Method signature:
int maxProfit(String companyName)
(be sure your method is public)

Constraints

  • companyName will contain between 1 and 50 characters, inclusive.
  • companyName will contain only lowercase letters ('a'..'z').

Examples

  1. "contest"
    Returns: 59
    The name that maximizes the profit is "conTeST". Each 'T' adds 20 to the profit, and the 'S' adds 19.
  2. "helloworld"
    Returns: 66
  3. "yep"
    Returns: 41
Back to all problems