File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
src/main/java/g2601_2700/s2678_number_of_senior_citizens Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 1
1
package g2601_2700 .s2678_number_of_senior_citizens ;
2
2
3
- // #Easy #Array #String #2023_09_11_Time_0_ms_ (100.00%)_Space_40.7_MB_(97.65 %)
3
+ // #Easy #Array #String #2025_02_26_Time_0_ms_ (100.00%)_Space_42.10_MB_(95.99 %)
4
4
5
5
public class Solution {
6
6
public int countSeniors (String [] details ) {
7
- int count = 0 ;
7
+ int seniorCitizen = 0 ;
8
8
for (String detail : details ) {
9
- if (detail .charAt (11 ) - '0' == 6 && detail .charAt (12 ) - '0' > 0
10
- || detail . charAt ( 11 ) - '0' > 6 ) {
11
- count ++;
9
+ int age = (detail .charAt (11 ) - '0' ) * 10 + detail .charAt (12 ) - '0' ;
10
+ if ( age > 60 ) {
11
+ seniorCitizen ++;
12
12
}
13
13
}
14
- return count ;
14
+ return seniorCitizen ;
15
15
}
16
16
}
You can’t perform that action at this time.
0 commit comments