TopcoderArchiveVisit Topcoder
Archive
Algorithm problem

VowelGame

Problem statement, definition, constraints, and public examples.

Problem Statement

You will be given a string of lowercase letters ('a'-'z'). Your job is to return how many vowels ('a','e','i','o','u') there are in the string.

Definition

Class:
VowelGame
Method:
countVowels
Parameters:
String
Returns:
int
Method signature:
int countVowels(String input)
(be sure your method is public)

Notes

  • 'y' is never a vowel in this problem

Constraints

  • input will contain between 0 and 50 characters inclusive
  • Each character in input will be a lowercase letter ('a'-'z')

Examples

  1. ""
    Returns: 0
    No characters
  2. "aeiou"
    Returns: 5
    All vowels
  3. "topcoder"
    Returns: 3
    2 'o's and 1 'e'
  4. "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    Returns: 50
    A lot of 'a's
  5. "czczczczczczczczc"
    Returns: 0
    No vowels here
  6. "yyyyyyyyyyyyyyyyyyyy"
    Returns: 0
    We never consider 'y' to be a vowel
Back to all problems