跳至主要内容

2678. Number of Senior Citizens

class Solution {
public:
int countSeniors(vector<string>& details)
{
int cnt = 0;
for (const auto& s : details)
{
int age = (s[11] - '0') * 10 + (s[12] - '0');
if (age > 60) ++cnt;
}
return cnt;
}
};
  • T: O(n)O(n)
  • S: O(1)O(1)