File tree 2 files changed +42
-0
lines changed
solution/2400-2499/2490.Circular Sentence
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -303,6 +303,27 @@ impl Solution {
303
303
}
304
304
```
305
305
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
+
306
327
### ** ...**
307
328
308
329
```
Original file line number Diff line number Diff line change @@ -281,6 +281,27 @@ impl Solution {
281
281
}
282
282
```
283
283
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
+
284
305
### ** ...**
285
306
286
307
```
You can’t perform that action at this time.
0 commit comments