824. Goat Latin Easy
1/**
2 * [824] Goat Latin
3 *
4 * You are given a string sentence that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only.
5 * We would like to convert the sentence to "Goat Latin" (a made-up language similar to Pig Latin.) The rules of Goat Latin are as follows:
6 *
7 * If a word begins with a vowel ('a', 'e', 'i', 'o', or 'u'), append "ma" to the end of the word.
8 *
9 * For example, the word "apple" becomes "applema".
10 *
11 *
12 * If a word begins with a consonant (i.e., not a vowel), remove the first letter and append it to the end, then add "ma".
13 *
14 * For example, the word "goat" becomes "oatgma".
15 *
16 *
17 * Add one letter 'a' to the end of each word per its word index in the sentence, starting with 1.
18 *
19 * For example, the first word gets "a" added to the end, the second word gets "aa" added to the end, and so on.
20 *
21 *
22 *
23 * Return the final sentence representing the conversion from sentence to Goat Latin.
24 *
25 * Example 1:
26 * Input: sentence = "I speak Goat Latin"
27 * Output: "Imaa peaksmaaa oatGmaaaa atinLmaaaaa"
28 * Example 2:
29 * Input: sentence = "The quick brown fox jumped over the lazy dog"
30 * Output: "heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa"
31 *
32 * Constraints:
33 *
34 * 1 <= sentence.length <= 150
35 * sentence consists of English letters and spaces.
36 * sentence has no leading or trailing spaces.
37 * All the words in sentence are separated by a single space.
38 *
39 */
40pub struct Solution {}
41
42// problem: https://leetcode.com/problems/goat-latin/
43// discuss: https://leetcode.com/problems/goat-latin/discuss/?currentPage=1&orderBy=most_votes&query=
44
45// submission codes start here
46
47impl Solution {
48 pub fn to_goat_latin(sentence: String) -> String {
49 String::new()
50 }
51}
52
53// submission codes end
54
55#[cfg(test)]
56mod tests {
57 use super::*;
58
59 #[test]
60 fn test_824() {
61 }
62}
63
Back
© 2025 bowen.ge All Rights Reserved.