Skip to content

Create 2678. Number of Senior Citizens #543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions 2678. Number of Senior Citizens
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Solution {
public:
int countSeniors(vector<string>& details) {
int cnt = 0; // Initialize counter for senior citizens

// Iterate through each detail string in the list
for(auto detail: details) {
// Extract age from the detail string
int age = (detail[11] - '0') * 10 + (detail[12] - '0');

// Check if the age is greater than 60
if(age > 60) {
++cnt; // Increment counter if the age is greater than 60
}
}

return cnt; // Return the total count of senior citizens
}
};
Loading