Skip to content

Commit

Permalink
Create 30-circular-sentence.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jun 30, 2023
1 parent 9bc8d0f commit 53a439c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions 2023/06/30-circular-sentence.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
impl Solution {
pub fn is_circular_sentence(sentence: String) -> bool {
let words = sentence.split_whitespace().collect::<Vec<_>>();
for i in 1..words.len() {
if words[i-1].as_bytes()[words[i-1].len()-1] != words[i].as_bytes()[0] {
return false;
}
}
words[0].as_bytes()[0] == words.last().unwrap().as_bytes()[words.last().unwrap().len() - 1]
}
}

0 comments on commit 53a439c

Please sign in to comment.