blob: 454381d77add9282a07a5a8d1bdf0d39a6c67aed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
struct Solution;
impl Solution {
pub fn detect_capital_use(word: String) -> bool {
let v: Vec<char> = word.chars().collect();
if v[0].is_lowercase() {
return v.iter().all(|&c| c.is_lowercase());
}
if v.len() > 1 {
let b = v[1].is_lowercase();
return v.iter().skip(1).all(|&c| c.is_lowercase() == b);
}
true
}
}
fn main() {
let word = String::from("USA");
print!("{}", Solution::detect_capital_use(word)); //true
}
|