Skip to content

Commit 2b3ab0c

Browse files
authored
feat: add rust solution to lc problem: No.2490 (#1305)
Signed-off-by: xiaolatiao <1628652790@qq.com>
1 parent ab09165 commit 2b3ab0c

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

solution/2400-2499/2490.Circular Sentence/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,27 @@ impl Solution {
303303
}
304304
```
305305

306+
```rust
307+
impl Solution {
308+
pub fn is_circular_sentence(sentence: String) -> bool {
309+
let n = sentence.len();
310+
let chars: Vec<char> = sentence.chars().collect();
311+
312+
if chars[0] != chars[n - 1] {
313+
return false;
314+
}
315+
316+
for i in 1..n - 1 {
317+
if chars[i] == ' ' && chars[i - 1] != chars[i + 1] {
318+
return false;
319+
}
320+
}
321+
322+
true
323+
}
324+
}
325+
```
326+
306327
### **...**
307328

308329
```

solution/2400-2499/2490.Circular Sentence/README_EN.md

+21
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,27 @@ impl Solution {
281281
}
282282
```
283283

284+
```rust
285+
impl Solution {
286+
pub fn is_circular_sentence(sentence: String) -> bool {
287+
let n = sentence.len();
288+
let chars: Vec<char> = sentence.chars().collect();
289+
290+
if chars[0] != chars[n - 1] {
291+
return false;
292+
}
293+
294+
for i in 1..n - 1 {
295+
if chars[i] == ' ' && chars[i - 1] != chars[i + 1] {
296+
return false;
297+
}
298+
}
299+
300+
true
301+
}
302+
}
303+
```
304+
284305
### **...**
285306

286307
```

0 commit comments

Comments
 (0)