557. Reverse Words in a String III Easy

@problem@discussion
#Two Pointers#String



1/**
2 * [557] Reverse Words in a String III
3 *
4 * Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
5 *  
6 * Example 1:
7 * Input: s = "Let's take LeetCode contest"
8 * Output: "s'teL ekat edoCteeL tsetnoc"
9 * Example 2:
10 * Input: s = "God Ding"
11 * Output: "doG gniD"
12 *  
13 * Constraints:
14 * 
15 * 	1 <= s.length <= 5 * 10^4
16 * 	s contains printable ASCII characters.
17 * 	s does not contain any leading or trailing spaces.
18 * 	There is at least one word in s.
19 * 	All the words in s are separated by a single space.
20 * 
21 */
22pub struct Solution {}
23
24// problem: https://leetcode.com/problems/reverse-words-in-a-string-iii/
25// discuss: https://leetcode.com/problems/reverse-words-in-a-string-iii/discuss/?currentPage=1&orderBy=most_votes&query=
26
27// submission codes start here
28
29impl Solution {
30    pub fn reverse_words(s: String) -> String {
31        String::new()
32    }
33}
34
35// submission codes end
36
37#[cfg(test)]
38mod tests {
39    use super::*;
40
41    #[test]
42    fn test_557() {
43    }
44}
45


Back
© 2025 bowen.ge All Rights Reserved.