Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbeebc13

Browse files
authored
Improved tasks 2678, 2679, 2706, 2703, 2711
1 parentb900a04 commitbeebc13

File tree

5 files changed

+10
-20
lines changed

5 files changed

+10
-20
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
packageg2601_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

55
publicclassSolution {
66
publicintcountSeniors(String[]details) {
7-
intcount =0;
7+
intseniorCitizen =0;
88
for (Stringdetail :details) {
9-
if (((detail.charAt(11) -'0' ==6) && (detail.charAt(12) -'0' >0))
10-
|| (detail.charAt(11) -'0' >6)) {
11-
count++;
9+
intage = (detail.charAt(11) -'0') *10 +detail.charAt(12) -'0';
10+
if (age >60) {
11+
seniorCitizen++;
1212
}
1313
}
14-
returncount;
14+
returnseniorCitizen;
1515
}
1616
}

‎src/main/java/g2601_2700/s2679_sum_in_a_matrix/Solution.java‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,17 @@
88
publicclassSolution {
99
publicintmatrixSum(int[][]nums) {
1010
intresult =0;
11-
1211
for (int[]row :nums) {
1312
Arrays.sort(row);
1413
reverseArray(row);
1514
}
16-
1715
for (inti =0;i <nums[0].length;i++) {
1816
intmax =0;
1917
for (int[]num :nums) {
2018
max =Math.max(max,num[i]);
2119
}
2220
result +=max;
2321
}
24-
2522
returnresult;
2623
}
2724

‎src/main/java/g2701_2800/s2703_return_length_of_arguments_passed/solution.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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-
functionargumentsLength(...args:any[]):number{
3+
typeJSONValue=null|boolean|number|string|JSONValue[]|{[key:string]:JSONValue};
4+
5+
functionargumentsLength(...args:JSONValue[]):number{
46
returnargs.length
57
}
68

‎src/main/java/g2701_2800/s2706_buy_two_chocolates/Solution.java‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ public class Solution {
66
publicintbuyChoco(int[]prices,intmoney) {
77
intminPrice1 =Integer.MAX_VALUE;
88
intminPrice2 =Integer.MAX_VALUE;
9-
109
for (intprice :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
inttotalPrice =minPrice1 +minPrice2;
20-
2118
if (totalPrice >money) {
2219
returnmoney;
2320
}else {

‎src/main/java/g2701_2800/s2711_difference_of_number_of_distinct_values_on_diagonals/Solution.java‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public int[][] differenceOfDistinctValues(int[][] grid) {
1111
intn =grid[0].length;
1212
int[][]arrTopLeft =newint[m][n];
1313
int[][]arrBotRight =newint[m][n];
14-
1514
for (inti =m -1;i >=0;i--) {
1615
intc =0;
1716
intr =i;
@@ -21,7 +20,6 @@ public int[][] differenceOfDistinctValues(int[][] grid) {
2120
set.add(grid[r++][c++]);
2221
}
2322
}
24-
2523
for (inti =1;i <n;i++) {
2624
intr =0;
2725
intc =i;
@@ -31,7 +29,6 @@ public int[][] differenceOfDistinctValues(int[][] grid) {
3129
set.add(grid[r++][c++]);
3230
}
3331
}
34-
3532
for (inti =0;i <n;i++) {
3633
intr =m -1;
3734
intc =i;
@@ -41,7 +38,6 @@ public int[][] differenceOfDistinctValues(int[][] grid) {
4138
set.add(grid[r--][c--]);
4239
}
4340
}
44-
4541
for (inti =m -1;i >=0;i--) {
4642
intc =n -1;
4743
intr =i;
@@ -51,14 +47,12 @@ public int[][] differenceOfDistinctValues(int[][] grid) {
5147
set.add(grid[r--][c--]);
5248
}
5349
}
54-
5550
int[][]result =newint[m][n];
5651
for (intr =0;r <m;r++) {
5752
for (intc =0;c <n;c++) {
5853
result[r][c] =Math.abs(arrTopLeft[r][c] -arrBotRight[r][c]);
5954
}
6055
}
61-
6256
returnresult;
6357
}
6458

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp