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

Commit74443f6

Browse files
authored
Added tasks 3643-3646
1 parent280b33c commit74443f6

File tree

24 files changed

+541
-51
lines changed

24 files changed

+541
-51
lines changed

‎src/main/java/g3601_3700/s3627_maximum_median_sum_of_subsequences_of_size_3/Solution.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packageg3601_3700.s3627_maximum_median_sum_of_subsequences_of_size_3;
22

3-
// #Medium #Weekly_Contest_460 #2025_07_27_Time_22_ms_(100.00%)_Space_129.50_MB_(86.95%)
3+
// #Medium #Array #Math #Sorting #Greedy #Game_Theory #Weekly_Contest_460
4+
// #2025_08_14_Time_23_ms_(98.36%)_Space_129.60_MB_(75.26%)
45

56
importjava.util.Arrays;
67

‎src/main/java/g3601_3700/s3628_maximum_number_of_subsequences_after_one_inserting/Solution.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packageg3601_3700.s3628_maximum_number_of_subsequences_after_one_inserting;
22

3-
// #Medium #Weekly_Contest_460 #2025_07_27_Time_12_ms_(100.00%)_Space_45.76_MB_(72.28%)
3+
// #Medium #String #Dynamic_Programming #Greedy #Prefix_Sum #Weekly_Contest_460
4+
// #2025_08_14_Time_12_ms_(100.00%)_Space_45.79_MB_(76.82%)
45

56
publicclassSolution {
67
publiclongnumOfSubsequences(Strings) {

‎src/main/java/g3601_3700/s3629_minimum_jumps_to_reach_end_via_prime_teleportation/Solution.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packageg3601_3700.s3629_minimum_jumps_to_reach_end_via_prime_teleportation;
22

3-
// #Medium #Weekly_Contest_460 #2025_07_27_Time_116_ms_(99.81%)_Space_76.00_MB_(67.96%)
3+
// #Medium #Array #Hash_Table #Math #Breadth_First_Search #Number_Theory #Weekly_Contest_460
4+
// #2025_08_14_Time_112_ms_(99.76%)_Space_76.04_MB_(74.71%)
45

56
importjava.util.ArrayDeque;
67
importjava.util.ArrayList;

‎src/main/java/g3601_3700/s3633_earliest_finish_time_for_land_and_water_rides_i/Solution.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packageg3601_3700.s3633_earliest_finish_time_for_land_and_water_rides_i;
22

3-
// #Easy #Biweekly_Contest_162 #2025_08_03_Time_3_ms_(100.00%)_Space_45.04_MB_(33.33%)
3+
// #Easy #Array #Sorting #Greedy #Binary_Search #Two_Pointers #Biweekly_Contest_162
4+
// #2025_08_14_Time_3_ms_(93.86%)_Space_45.39_MB_(29.02%)
45

56
publicclassSolution {
67
publicintearliestFinishTime(

‎src/main/java/g3601_3700/s3634_minimum_removals_to_balance_array/Solution.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packageg3601_3700.s3634_minimum_removals_to_balance_array;
22

3-
// #Medium #Biweekly_Contest_162 #2025_08_03_Time_21_ms_(100.00%)_Space_60.28_MB_(100.00%)
3+
// #Medium #Array #Sorting #Sliding_Window #Biweekly_Contest_162
4+
// #2025_08_14_Time_20_ms_(99.40%)_Space_60.70_MB_(34.02%)
45

56
importjava.util.Arrays;
67

‎src/main/java/g3601_3700/s3635_earliest_finish_time_for_land_and_water_rides_ii/Solution.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packageg3601_3700.s3635_earliest_finish_time_for_land_and_water_rides_ii;
22

3-
// #Medium #Biweekly_Contest_162 #2025_08_03_Time_2_ms_(100.00%)_Space_55.88_MB_(50.00%)
3+
// #Medium #Array #Sorting #Greedy #Binary_Search #Two_Pointers #Biweekly_Contest_162
4+
// #2025_08_14_Time_2_ms_(100.00%)_Space_55.78_MB_(68.53%)
45

56
publicclassSolution {
67
publicintearliestFinishTime(

‎src/main/java/g3601_3700/s3636_threshold_majority_queries/Solution.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packageg3601_3700.s3636_threshold_majority_queries;
22

3-
// #Hard #Biweekly_Contest_162 #2025_08_06_Time_82_ms_(98.38%)_Space_71.28_MB_(74.76%)
3+
// #Hard #Array #Hash_Table #Binary_Search #Prefix_Sum #Counting #Divide_and_Conquer
4+
// #Biweekly_Contest_162 #2025_08_14_Time_83_ms_(96.87%)_Space_71.30_MB_(75.24%)
45

56
importjava.util.ArrayList;
67
importjava.util.Arrays;
Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
packageg3601_3700.s3637_trionic_array_i;
22

3-
// #Easy #Weekly_Contest_461 #2025_08_03_Time_1_ms_(100.00%)_Space_42.62_MB_(100.00%)
3+
// #Easy #Array #Weekly_Contest_461 #2025_08_14_Time_0_ms_(100.00%)_Space_43.15_MB_(44.56%)
44

55
publicclassSolution {
66
publicbooleanisTrionic(int[]nums) {
7-
intp =0;
8-
intq =0;
7+
inti =1;
98
intn =nums.length;
10-
for (inti =1;i <n -1; ++i) {
11-
if (nums[i -1] ==nums[i]) {
12-
returnfalse;
13-
}
14-
if (nums[i -1] <nums[i] &&nums[i] >nums[i +1]) {
15-
if (p !=0) {
16-
returnfalse;
17-
}
18-
p =i;
19-
}
20-
if (nums[i -1] >nums[i] &&nums[i] <nums[i +1]) {
21-
if (p ==0 ||q !=0) {
22-
returnfalse;
23-
}
24-
q =i;
25-
}
9+
while (i <n &&nums[i] >nums[i -1]) {
10+
i++;
2611
}
27-
returnq >0;
12+
if (i ==n ||i ==1) {
13+
returnfalse;
14+
}
15+
while (i <n &&nums[i] <nums[i -1]) {
16+
i++;
17+
}
18+
if (i ==n) {
19+
returnfalse;
20+
}
21+
while (i <n &&nums[i] >nums[i -1]) {
22+
i++;
23+
}
24+
returni ==n;
2825
}
2926
}

‎src/main/java/g3601_3700/s3638_maximum_balanced_shipments/Solution.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packageg3601_3700.s3638_maximum_balanced_shipments;
22

3-
// #Medium #Weekly_Contest_461 #2025_08_03_Time_3_ms_(100.00%)_Space_62.17_MB_(100.00%)
3+
// #Medium #Array #Dynamic_Programming #Greedy #Stack #Monotonic_Stack #Weekly_Contest_461
4+
// #2025_08_14_Time_2_ms_(100.00%)_Space_62.34_MB_(68.23%)
45

56
publicclassSolution {
67
publicintmaxBalancedShipments(int[]weight) {
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
packageg3601_3700.s3639_minimum_time_to_activate_string;
22

3-
// #Medium #Weekly_Contest_461 #2025_08_03_Time_122_ms_(100.00%)_Space_58.43_MB_(100.00%)
4-
5-
importjava.util.TreeSet;
3+
// #Medium #Array #Binary_Search #Weekly_Contest_461
4+
// #2025_08_14_Time_6_ms_(99.91%)_Space_57.07_MB_(91.05%)
65

76
publicclassSolution {
87
publicintminTime(Strings,int[]order,intk) {
98
intn =s.length();
10-
// Use a TreeSet to maintain a sorted list of indices
11-
TreeSet<Integer>pos =newTreeSet<>();
12-
pos.add(-1);
13-
pos.add(n);
14-
// Iterate through the order of removal
15-
intlocalK =k;
16-
for (intt =0;t <order.length; ++t) {
9+
longtotal =n * (n +1L) /2;
10+
if (total <k) {
11+
return -1;
12+
}
13+
int[]prev =newint[n +1];
14+
int[]next =newint[n +1];
15+
for (inti =0;i <n; ++i) {
16+
prev[i] =i -1;
17+
next[i] =i +1;
18+
}
19+
for (intt =n -1;t >=0;t--) {
1720
inti =order[t];
18-
// Find the elements in the sorted set that bracket the current index 'i'
19-
// 'r' is the smallest element >= i
20-
Integerr =pos.ceiling(i);
21-
// 'l' is the largest element <= i
22-
Integerl =pos.floor(i);
23-
// The 'cost' to remove an item is the product of the distances to its neighbors
24-
localK -= (int) ((long) (i -l) * (r -i));
25-
pos.add(i);
26-
// If the total cost is exhausted, return the current time 't'
27-
if (localK <=0) {
21+
intleft =prev[i];
22+
intright =next[i];
23+
total -= (long) (i -left) * (right -i);
24+
if (total <k) {
2825
returnt;
2926
}
27+
if (left >=0) {
28+
next[left] =right;
29+
}
30+
prev[right] =left;
3031
}
31-
// If all items are removed and k is not exhausted, return -1
32-
return -1;
32+
return0;
3333
}
3434
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp