✔💯 DAY 408 | ONE LINER | 100% | | [PYTHON/JAVA/C++] | EXPLAINED 🆙🆙🆙
Please Upvote as it really motivates me \uD83C\uDD99\uD83C\uDD99\uD83C\uDD99\nIterates over each string in the input array, and extracts the age of the person f
# Please Upvote as it really motivates me \uD83C\uDD99\uD83C\uDD99\uD83C\uDD99\nIterates over each string in the input array, and extracts the age of the person from the string using the \nsubstring method and the  parseInt method. If the age is greater than 60, the function increments the count. Finally, the function returns the count.\n\n# Complexity\nThe time complexity of this function is O(n), where n is the number of strings in the input array, since we need to iterate over each string in the array. The space complexity is O(1), since we only need to store the count of seniors in memory.\n\n\n\n# Code\n```java []\n    public int countSeniors(String[] details) {\n        int cnt=0;\n        for(String tem:details){\n            int age = Integer.parseInt(tem.substring(11,13));\n            if(age>60)cnt++;\n        }return cnt;\n        \n    }\n```\n```c++ []\nint countSeniors(vector<string>& details) {\n    int cnt = 0;\n    for (string tem : details) {\n        int age = stoi(tem.substr(11, 2));\n        if (age > 60) {\n            cnt++;\n        }\n    }\n    return cnt;\n}\n```\n```python []\ndef countSeniors(details: List[str]) -> int:\n    cnt = 0\n    for tem in details:\n        age = int(tem[11:13])\n        if age > 60:\n            cnt += 1\n    return cnt\n```\n# ONE LINER\n\n```PYTHON  []\ndef countSeniors(details: List[str]) -> int:\n    return sum(int(detail[11:13]) > 60 for detail in details)\n```\n```C++ []\nint countSeniors(vector<string>& details) {\n    return count_if(details.begin(), details.end(), [](string detail) {\n        int age = stoi(detail.substr(11, 2));\n        return age > 60;\n    });\n}\n```\n```JAVA []\npublic int countSeniors(String[] details) {\n        return (int) Arrays.stream(details)\n                .mapToInt(detail -> Integer.parseInt(detail.substring(11, 13)))\n                .filter(age -> age > 60)\n                .count();\n    }\n```
['String', 'Python', 'C++', 'Java', 'Python3']