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
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
"Hawaii is an island"
Returns: { "Hawaii", "an" }
's' is not a valid letter in Hawaiian, so "is" and "island" cannot be Hawaiian words.
"Mauna Kea and Mauna Koa are two mountains"
Returns: { "Mauna", "Kea", "Mauna", "Koa" }
"Lanai Kawai Molokai"
Returns: { "Lanai", "Kawai", "Molokai" }
"a e i o u are vowels"
Returns: { "a", "e", "i", "o", "u" }
"hello world"
Returns: { "hello" }
"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" }
"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" }
"Pineapple grows in Hawaii"
Returns: { "Pineapple", "in", "Hawaii" }
"This is a test sentence"
Returns: { "a" }
"The quick brown dog jumped over the lazy gray fox"
Returns: { }
"Problems like this are meant to be solved"
Returns: { "like" }
"One word return value"
Returns: { "One" }
"Je suis francais mais je parle anglais"
Returns: { }
"Hablamos espanol pero no hablamos engles"
Returns: { "no" }
"ab un ch of ga rb ag ed ip th on gs"
Returns: { "un", "ip", "on" }
"aeiouhklmnpwaeiouhklmnpwaeiouhklmnpwaeiouhklmnpw"
Returns: { "aeiouhklmnpwaeiouhklmnpwaeiouhklmnpwaeiouhklmnpw" }
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
Returns: { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz"
Returns: { }
"xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
Returns: { }
"hhhhhaaaaaeeeeeIIoooiiiippplknm"
Returns: { "hhhhhaaaaaeeeeeIIoooiiiippplknm" }
"Mauna Kea and Mauna Koa are two mountains"
Returns: { "Mauna", "Kea", "Mauna", "Koa" }
"HW hw kW ff aE AE ea io ui hw adb adlkjf BD DD"
Returns: { "HW", "hw", "kW", "aE", "AE", "ea", "io", "ui", "hw" }
"Pineapple grows in Hawaii AE ZZ ae Ae Za"
Returns: { "Pineapple", "in", "Hawaii", "AE", "ae", "Ae" }
"a a a a"
Returns: { "a", "a", "a", "a" }
"cccccc"
Returns: { }
"Hawaii is an island"
Returns: { "Hawaii", "an" }
"BCD FGJ"
Returns: { }
"WWW WW wW W"
Returns: { "WWW", "WW", "wW", "W" }
"A E"
Returns: { "A", "E" }
"a A b B ab AB Ab aB"
Returns: { "a", "A" }
"aei"
Returns: { "aei" }
"UU UU UU UU helloU hello helloU"
Returns: { "UU", "UU", "UU", "UU", "helloU", "hello", "helloU" }