We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 080b638 + b9f64ea commit 5200410Copy full SHA for 5200410
2678. Number of Senior Citizens
@@ -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