-
Notifications
You must be signed in to change notification settings - Fork 13
/
solution.cpp
29 lines (25 loc) · 866 Bytes
/
solution.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <vector>
#include <string>
using namespace std;
class Solution
{
public:
int countSeniors(vector<string> &details)
{
int count = 0; // Initialize a counter to keep track of seniors
// Iterate through each detail in the details vector
for (const string &detail : details)
{
// Extract the substring representing the age, assuming the age is always at the same position
string age_str = detail.substr(11, 2);
// Convert the extracted substring to an integer to get the age
int age = stoi(age_str);
// Check if the extracted age is greater than 60
if (age > 60)
{
count++; // Increment the counter if the person is a senior
}
}
return count; // Return the total count of seniors
}
};