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 11package g2601_2700 .s2678_number_of_senior_citizens ;
22
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 %)
44
55public class Solution {
66 public int countSeniors (String [] details ) {
7- int count = 0 ;
7+ int seniorCitizen = 0 ;
88 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 ++;
1212 }
1313 }
14- return count ;
14+ return seniorCitizen ;
1515 }
1616}
You can’t perform that action at this time.
0 commit comments