File tree Expand file tree Collapse file tree 5 files changed +10
-20
lines changed
s2678_number_of_senior_citizens
s2703_return_length_of_arguments_passed
s2711_difference_of_number_of_distinct_values_on_diagonals Expand file tree Collapse file tree 5 files changed +10
-20
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}
Original file line number Diff line number Diff line change 88public class Solution {
99 public int matrixSum (int [][] nums ) {
1010 int result = 0 ;
11-
1211 for (int [] row : nums ) {
1312 Arrays .sort (row );
1413 reverseArray (row );
1514 }
16-
1715 for (int i = 0 ; i < nums [0 ].length ; i ++) {
1816 int max = 0 ;
1917 for (int [] num : nums ) {
2018 max = Math .max (max , num [i ]);
2119 }
2220 result += max ;
2321 }
24-
2522 return result ;
2623 }
2724
Original file line number Diff line number Diff line change 1- // #Easy #2023_09_14_Time_49_ms_(86.01%)_Space_42.9_MB_(39.39 %)
1+ // #Easy #2025_02_26_Time_50_ms_(82.03%)_Space_54.95_MB_(7.19 %)
22
3- function argumentsLength ( ...args : any [ ] ) : number {
3+ type JSONValue = null | boolean | number | string | JSONValue [ ] | { [ key : string ] : JSONValue } ;
4+
5+ function argumentsLength ( ...args : JSONValue [ ] ) : number {
46 return args . length
57}
68
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ public class Solution {
66 public int buyChoco (int [] prices , int money ) {
77 int minPrice1 = Integer .MAX_VALUE ;
88 int minPrice2 = Integer .MAX_VALUE ;
9-
109 for (int price : prices ) {
1110 if (price < minPrice1 ) {
1211 minPrice2 = minPrice1 ;
@@ -15,9 +14,7 @@ public int buyChoco(int[] prices, int money) {
1514 minPrice2 = price ;
1615 }
1716 }
18-
1917 int totalPrice = minPrice1 + minPrice2 ;
20-
2118 if (totalPrice > money ) {
2219 return money ;
2320 } else {
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ public int[][] differenceOfDistinctValues(int[][] grid) {
1111 int n = grid [0 ].length ;
1212 int [][] arrTopLeft = new int [m ][n ];
1313 int [][] arrBotRight = new int [m ][n ];
14-
1514 for (int i = m - 1 ; i >= 0 ; i --) {
1615 int c = 0 ;
1716 int r = i ;
@@ -21,7 +20,6 @@ public int[][] differenceOfDistinctValues(int[][] grid) {
2120 set .add (grid [r ++][c ++]);
2221 }
2322 }
24-
2523 for (int i = 1 ; i < n ; i ++) {
2624 int r = 0 ;
2725 int c = i ;
@@ -31,7 +29,6 @@ public int[][] differenceOfDistinctValues(int[][] grid) {
3129 set .add (grid [r ++][c ++]);
3230 }
3331 }
34-
3532 for (int i = 0 ; i < n ; i ++) {
3633 int r = m - 1 ;
3734 int c = i ;
@@ -41,7 +38,6 @@ public int[][] differenceOfDistinctValues(int[][] grid) {
4138 set .add (grid [r --][c --]);
4239 }
4340 }
44-
4541 for (int i = m - 1 ; i >= 0 ; i --) {
4642 int c = n - 1 ;
4743 int r = i ;
@@ -51,14 +47,12 @@ public int[][] differenceOfDistinctValues(int[][] grid) {
5147 set .add (grid [r --][c --]);
5248 }
5349 }
54-
5550 int [][] result = new int [m ][n ];
5651 for (int r = 0 ; r < m ; r ++) {
5752 for (int c = 0 ; c < n ; c ++) {
5853 result [r ][c ] = Math .abs (arrTopLeft [r ][c ] - arrBotRight [r ][c ]);
5954 }
6055 }
61-
6256 return result ;
6357 }
6458
You can’t perform that action at this time.
0 commit comments