Skip to content

Commit 4ab0f78

Browse files
authored
Added tasks 3701-3704
1 parent 3f1908f commit 4ab0f78

File tree

20 files changed

+428
-8
lines changed

20 files changed

+428
-8
lines changed

src/main/kotlin/g3601_3700/s3692_majority_frequency_characters/Solution.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package g3601_3700.s3692_majority_frequency_characters
22

3-
// #Easy #Biweekly_Contest_166 #2025_10_03_Time_2_ms_(100.00%)_Space_43.05_MB_(100.00%)
3+
// #Easy #String #Hash_Table #Counting #Biweekly_Contest_166
4+
// #2025_10_03_Time_2_ms_(100.00%)_Space_43.05_MB_(100.00%)
45

56
class Solution {
67
fun majorityFrequencyGroup(s: String): String {

src/main/kotlin/g3601_3700/s3693_climbing_stairs_ii/Solution.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package g3601_3700.s3693_climbing_stairs_ii
22

3-
// #Medium #Biweekly_Contest_166 #2025_10_03_Time_8_ms_(100.00%)_Space_80.61_MB_(12.90%)
3+
// #Medium #Array #Dynamic_Programming #Biweekly_Contest_166
4+
// #2025_10_03_Time_8_ms_(100.00%)_Space_80.61_MB_(12.90%)
45

56
import kotlin.math.min
67

src/main/kotlin/g3601_3700/s3694_distinct_points_reachable_after_substring_removal/Solution.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package g3601_3700.s3694_distinct_points_reachable_after_substring_removal
22

3-
// #Medium #Biweekly_Contest_166 #2025_10_03_Time_46_ms_(100.00%)_Space_48.62_MB_(100.00%)
3+
// #Medium #String #Hash_Table #Prefix_Sum #Sliding_Window #Biweekly_Contest_166
4+
// #2025_10_03_Time_46_ms_(100.00%)_Space_48.62_MB_(100.00%)
45

56
class Solution {
67
fun distinctPoints(s: String, k: Int): Int {

src/main/kotlin/g3601_3700/s3695_maximize_alternating_sum_using_swaps/Solution.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package g3601_3700.s3695_maximize_alternating_sum_using_swaps
22

3-
// #Hard #Biweekly_Contest_166 #2025_10_03_Time_61_ms_(100.00%)_Space_105.29_MB_(100.00%)
3+
// #Hard #Array #Sorting #Greedy #Union_Find #Biweekly_Contest_166
4+
// #2025_10_03_Time_61_ms_(100.00%)_Space_105.29_MB_(100.00%)
45

56
class Solution {
67
private lateinit var root: IntArray

src/main/kotlin/g3601_3700/s3697_compute_decimal_representation/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package g3601_3700.s3697_compute_decimal_representation
22

3-
// #Easy #Weekly_Contest_469 #2025_10_03_Time_1_ms_(100.00%)_Space_42.64_MB_(100.00%)
3+
// #Easy #Array #Math #Weekly_Contest_469 #2025_10_03_Time_1_ms_(100.00%)_Space_42.64_MB_(100.00%)
44

55
class Solution {
66
fun decimalRepresentation(n: Int): IntArray {

src/main/kotlin/g3601_3700/s3698_split_array_with_minimum_difference/Solution.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package g3601_3700.s3698_split_array_with_minimum_difference
22

3-
// #Medium #Weekly_Contest_469 #2025_10_03_Time_3_ms_(100.00%)_Space_69.93_MB_(52.17%)
3+
// #Medium #Array #Prefix_Sum #Weekly_Contest_469
4+
// #2025_10_03_Time_3_ms_(100.00%)_Space_69.93_MB_(52.17%)
45

56
import kotlin.math.abs
67
import kotlin.math.min

src/main/kotlin/g3601_3700/s3699_number_of_zigzag_arrays_i/Solution.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package g3601_3700.s3699_number_of_zigzag_arrays_i
22

3-
// #Hard #Weekly_Contest_469 #2025_10_03_Time_227_ms_(78.57%)_Space_47.61_MB_(42.86%)
3+
// #Hard #Dynamic_Programming #Prefix_Sum #Weekly_Contest_469
4+
// #2025_10_03_Time_227_ms_(78.57%)_Space_47.61_MB_(42.86%)
45

56
class Solution {
67
fun zigZagArrays(n: Int, l: Int, r: Int): Int {

src/main/kotlin/g3601_3700/s3700_number_of_zigzag_arrays_ii/Solution.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package g3601_3700.s3700_number_of_zigzag_arrays_ii
22

3-
// #Hard #Weekly_Contest_469 #2025_10_03_Time_175_ms_(100.00%)_Space_49.83_MB_(50.00%)
3+
// #Hard #Dynamic_Programming #Math #Weekly_Contest_469
4+
// #2025_10_03_Time_175_ms_(100.00%)_Space_49.83_MB_(50.00%)
45

56
class Solution {
67
fun zigZagArrays(n: Int, l: Int, r: Int): Int {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package g3701_3800.s3701_compute_alternating_sum
2+
3+
// #Easy #Weekly_Contest_470 #2025_10_06_Time_1_ms_(100.00%)_Space_47.16_MB_(11.11%)
4+
5+
class Solution {
6+
fun alternatingSum(nums: IntArray): Int {
7+
var sum = 0
8+
for (i in nums.indices) {
9+
val num = nums[i]
10+
if (i % 2 == 0) {
11+
sum += num
12+
} else {
13+
sum -= num
14+
}
15+
}
16+
return sum
17+
}
18+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
3701\. Compute Alternating Sum
2+
3+
Easy
4+
5+
You are given an integer array `nums`.
6+
7+
The **alternating sum** of `nums` is the value obtained by **adding** elements at even indices and **subtracting** elements at odd indices. That is, `nums[0] - nums[1] + nums[2] - nums[3]...`
8+
9+
Return an integer denoting the alternating sum of `nums`.
10+
11+
**Example 1:**
12+
13+
**Input:** nums = [1,3,5,7]
14+
15+
**Output:** \-4
16+
17+
**Explanation:**
18+
19+
* Elements at even indices are `nums[0] = 1` and `nums[2] = 5` because 0 and 2 are even numbers.
20+
* Elements at odd indices are `nums[1] = 3` and `nums[3] = 7` because 1 and 3 are odd numbers.
21+
* The alternating sum is `nums[0] - nums[1] + nums[2] - nums[3] = 1 - 3 + 5 - 7 = -4`.
22+
23+
**Example 2:**
24+
25+
**Input:** nums = [100]
26+
27+
**Output:** 100
28+
29+
**Explanation:**
30+
31+
* The only element at even indices is `nums[0] = 100` because 0 is an even number.
32+
* There are no elements on odd indices.
33+
* The alternating sum is `nums[0] = 100`.
34+
35+
**Constraints:**
36+
37+
* `1 <= nums.length <= 100`
38+
* `1 <= nums[i] <= 100`

0 commit comments

Comments
 (0)