Optimized Solution
IntuitionWe need to extract the age from a string at fixed positions and check if it’s greater than 60. The age is always in the same position in each string, s
# Intuition
We need to extract the age from a string at fixed positions and check if it’s greater than 60. The age is always in the same position in each string, so we can directly access those characters.
# Approach
I use charAt() to access the characters representing the age, convert them to integers, and check if the age is greater than 60. This avoids unnecessary string creation, making the solution more efficient.

# Complexity
- Time complexity:
𝑂(𝑛), where n is the length of the details array.I iterate through each string once, performing constant-time operations for each string.

- Space complexity:
𝑂(1). I use only a fixed amount of extra space (for the count and temporary variables).

# Code
```java []
class Solution {
    public int countSeniors(String[] details) {
        int count=0;
        for(int i=0;i<details.length;i++)
        {
            for (String passengers : details) {
            int age = (passengers.charAt(11) - '0') * 10 + (passengers.charAt(12) - '0'); 
            if (age > 60) {
                count++;
            }
        }
        return count;    
}
```
['Java']