Statistics

Problem Statement for "Hawaiian"

Problem Statement

Many languages, including English, French, Spanish, and German use Latin characters (a-z). Hawaiian, as well, uses these characters. However, only a small subset of these characters are used in the Hawaiian alphabet - the five vowels: 'a', 'e', 'i', 'o', 'u', and seven consonants: 'h', 'k', 'l', 'm', 'n', 'p', 'w'. Given a sentence of words, you are to determine which could possibly be Hawaiian words. Anything which contains a letter not in the Hawaiian alphabet cannot be Hawaiian; every other word can be.

A word is defined as a contiguous sequence of letters. You will be given a sentence of words. You must tokenize them using a space (' ') as a delimiter, remove the words which cannot be Hawaiian, and return the rest in a String[], in the order in which they occur in the sentence, in the same case in which they appear in the sentence.

Definition

Class:
Hawaiian
Method:
getWords
Parameters:
String
Returns:
String[]
Method signature:
String[] getWords(String sentence)
(be sure your method is public)

Constraints

  • sentence will contain between 1 and 50 characters, inclusive.
  • Each character in sentence will be an uppercase or lowercase letter (A-Z, a-z), or a space.
  • sentence will not contain two consecutive spaces; that is, there will be exactly one space between words.
  • sentence will not begin or end with a space.

Examples

  1. "Hawaii is an island"

    Returns: { "Hawaii", "an" }

    's' is not a valid letter in Hawaiian, so "is" and "island" cannot be Hawaiian words.

  2. "Mauna Kea and Mauna Koa are two mountains"

    Returns: { "Mauna", "Kea", "Mauna", "Koa" }

  3. "Lanai Kawai Molokai"

    Returns: { "Lanai", "Kawai", "Molokai" }

  4. "a e i o u are vowels"

    Returns: { "a", "e", "i", "o", "u" }

  5. "hello world"

    Returns: { "hello" }

  6. "a b c d e f g h i j k l m n o p q r s t u v w x yz"

    Returns: { "a", "e", "h", "i", "k", "l", "m", "n", "o", "p", "u", "w" }

  7. "A B C D E F G HI J K L M N O P Q R S T U V W X Y Z"

    Returns: { "A", "E", "HI", "K", "L", "M", "N", "O", "P", "U", "W" }

  8. "Pineapple grows in Hawaii"

    Returns: { "Pineapple", "in", "Hawaii" }

  9. "This is a test sentence"

    Returns: { "a" }

  10. "The quick brown dog jumped over the lazy gray fox"

    Returns: { }

  11. "Problems like this are meant to be solved"

    Returns: { "like" }

  12. "One word return value"

    Returns: { "One" }

  13. "Je suis francais mais je parle anglais"

    Returns: { }

  14. "Hablamos espanol pero no hablamos engles"

    Returns: { "no" }

  15. "ab un ch of ga rb ag ed ip th on gs"

    Returns: { "un", "ip", "on" }

  16. "aeiouhklmnpwaeiouhklmnpwaeiouhklmnpwaeiouhklmnpw"

    Returns: { "aeiouhklmnpwaeiouhklmnpwaeiouhklmnpwaeiouhklmnpw" }

  17. "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

    Returns: { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }

  18. "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz"

    Returns: { }

  19. "xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

    Returns: { }

  20. "hhhhhaaaaaeeeeeIIoooiiiippplknm"

    Returns: { "hhhhhaaaaaeeeeeIIoooiiiippplknm" }

  21. "Mauna Kea and Mauna Koa are two mountains"

    Returns: { "Mauna", "Kea", "Mauna", "Koa" }

  22. "HW hw kW ff aE AE ea io ui hw adb adlkjf BD DD"

    Returns: { "HW", "hw", "kW", "aE", "AE", "ea", "io", "ui", "hw" }

  23. "Pineapple grows in Hawaii AE ZZ ae Ae Za"

    Returns: { "Pineapple", "in", "Hawaii", "AE", "ae", "Ae" }

  24. "a a a a"

    Returns: { "a", "a", "a", "a" }

  25. "cccccc"

    Returns: { }

  26. "Hawaii is an island"

    Returns: { "Hawaii", "an" }

  27. "BCD FGJ"

    Returns: { }

  28. "WWW WW wW W"

    Returns: { "WWW", "WW", "wW", "W" }

  29. "A E"

    Returns: { "A", "E" }

  30. "a A b B ab AB Ab aB"

    Returns: { "a", "A" }

  31. "aei"

    Returns: { "aei" }

  32. "UU UU UU UU helloU hello helloU"

    Returns: { "UU", "UU", "UU", "UU", "helloU", "hello", "helloU" }


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: