Skip to content

Commit 5200410

Browse files
authored
Create 2678. Number of Senior Citizens (#543)
2 parents 080b638 + b9f64ea commit 5200410

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

2678. Number of Senior Citizens

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public:
3+
int countSeniors(vector<string>& details) {
4+
int cnt = 0; // Initialize counter for senior citizens
5+
6+
// Iterate through each detail string in the list
7+
for(auto detail: details) {
8+
// Extract age from the detail string
9+
int age = (detail[11] - '0') * 10 + (detail[12] - '0');
10+
11+
// Check if the age is greater than 60
12+
if(age > 60) {
13+
++cnt; // Increment counter if the age is greater than 60
14+
}
15+
}
16+
17+
return cnt; // Return the total count of senior citizens
18+
}
19+
};

0 commit comments

Comments
 (0)