Skip to content

Commit b171634

Browse files
authored
Added solution for 2678
1 parent 45021ff commit b171634

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

02678. Number of Senior Citizens.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
impl Solution {
2+
// Loop through details vector. During each iteration, extract the age-specific strings and convert them into integer. Post conversion, check if they are greater than 60. Return the total count
3+
pub fn count_seniors(details: Vec<String>) -> i32 {
4+
let mut result = 0;
5+
for detail in details {
6+
let age = &detail[11..13].parse::<i32>().unwrap();
7+
if *age > 60 {
8+
result += 1;
9+
}
10+
}
11+
return result;
12+
}
13+
}

0 commit comments

Comments
 (0)