diff --git a/2678. Number of Senior Citizens b/2678. Number of Senior Citizens new file mode 100644 index 0000000..3b3c5eb --- /dev/null +++ b/2678. Number of Senior Citizens @@ -0,0 +1,19 @@ +class Solution { +public: + int countSeniors(vector& 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 + } +};