C# Solution for Number of Senior Citizens Problem
Intuition\n Describe your first thoughts on how to solve this problem. \nThe solution leverages LINQ\u2019s Count method along with a lambda expression to succi
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe solution leverages LINQ\u2019s Count method along with a lambda expression to succinctly and efficiently count the number of passengers who are over 60 years old. This approach focuses on using declarative programming to express the filtering and counting logic in a concise manner.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1.\tLambda Expression: The lambda expression detail => int.Parse(detail.Substring(11, 2)) > 60 is used within the Count method. This expression:\n\t\u2022\tExtracts the age substring from each detail string.\n\t\u2022\tParses the age substring into an integer.\n\t\u2022\tChecks if the parsed age is greater than 60.\n2.\tLINQ Count: The Count method iterates through each element in the details array, applies the lambda expression to each element, and counts how many elements satisfy the condition (int.Parse(detail.Substring(11, 2)) > 60).\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nThe time complexity of this solution is O(n), where n is the number of strings in the details array. The Count method iterates through each element exactly once, and the operations within the lambda expression (Substring, int.Parse, and comparison) are constant time operations.\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nThe space complexity is O(1) additional space, not counting the input array. The operations inside the lambda expression (Substring, int.Parse, comparison) use a constant amount of extra space, and the Count method itself operates in constant space.\n\n# Code\n```\npublic class Solution {\n    public int CountSeniors(string[] details) {\n        return details.Count(detail => int.Parse(detail.Substring(11, 2)) > 60);\n    }\n}\n```
['C#']