TopcoderArchiveVisit Topcoder
SRM22 Dec 2013
SRM 618

LongWordsDiv2

Problem statement, definition, constraints, and public examples.

Problem Statement

Fox Ciel likes all the words that have the following properties:
  1. Each letter of the word is an uppercase English letter.
  2. Equal letters are never consecutive.
  3. There is no subsequence of the form xyxy, where x and y are (not necessarily distinct) letters. Note that a subsequence doesn't have to be contiguous.
Examples:
  • Ciel does not like "ABBA" because there are two consecutive 'B's.
  • Ciel does not like "THETOPCODER" because it contains the subsequence "TETE".
  • Ciel does not like "ABACADA" because it contains the subsequence "AAAA". (Note that here x=y='A'.)
  • Ciel likes "A", "ABA", and also "ABCBA".
Given a String word, return "Likes" (quotes for clarity) if Ciel likes word and "Dislikes" if she does not.

Definition

Class:
LongWordsDiv2
Method:
find
Parameters:
String
Returns:
String
Method signature:
String find(String word)
(be sure your method is public)

Constraints

  • word will contain between 1 and 100 characters, inclusive.
  • Each character of word will be an uppercase English letter ('A'-'Z').

Examples

  1. "AAA"
    Returns: "Dislikes"
  2. "ABCBA"
    Returns: "Likes"
  3. "ABCBAC"
    Returns: "Dislikes"
  4. "TOPCODER"
    Returns: "Likes"
  5. "VAMOSGIMNASIA"
    Returns: "Dislikes"
  6. "SINGLEROUNDMATCH"
    Returns: "Likes"
  7. "DALELOBO"
    Returns: "Likes"
Back to all problems