(sentence: String)
| 1 | pub fn is_circular_sentence(sentence: String) -> bool { |
| 2 | if sentence.chars().nth(0).unwrap() != |
| 3 | sentence.chars().nth(sentence.len() - 1).unwrap() { |
| 4 | return false |
| 5 | } |
| 6 | let mut count = 0; |
| 7 | let mut prev_char: char = '?'; |
| 8 | for word in sentence.split_ascii_whitespace() { |
| 9 | if count == 0 { |
| 10 | prev_char = word.chars().last().unwrap() |
| 11 | } else { |
| 12 | let curr_char = word.chars().nth(0).unwrap(); |
| 13 | if curr_char != prev_char { return false } |
| 14 | prev_char = word.chars().last().unwrap(); |
| 15 | } |
| 16 | count += 1 |
| 17 | } |
| 18 | true |
| 19 | } |
| 20 | |
| 21 | fn main() { |
| 22 | let sentence = "leetcode exercises sound delightful".to_string(); |
nothing calls this directly
no outgoing calls
no test coverage detected