diff --git a/src/main/kotlin/g3401_3500/s3492_maximum_containers_on_a_ship/Solution.kt b/src/main/kotlin/g3401_3500/s3492_maximum_containers_on_a_ship/Solution.kt
new file mode 100644
index 000000000..99836bdbe
--- /dev/null
+++ b/src/main/kotlin/g3401_3500/s3492_maximum_containers_on_a_ship/Solution.kt
@@ -0,0 +1,13 @@
+package g3401_3500.s3492_maximum_containers_on_a_ship
+
+// #Easy #Math #2025_03_23_Time_0_ms_(100.00%)_Space_40.86_MB_(89.29%)
+
+import kotlin.math.min
+
+class Solution {
+ fun maxContainers(n: Int, w: Int, maxWeight: Int): Int {
+ val c = n * n
+ val count = maxWeight / w
+ return min(c, count)
+ }
+}
diff --git a/src/main/kotlin/g3401_3500/s3492_maximum_containers_on_a_ship/readme.md b/src/main/kotlin/g3401_3500/s3492_maximum_containers_on_a_ship/readme.md
new file mode 100644
index 000000000..991f16e56
--- /dev/null
+++ b/src/main/kotlin/g3401_3500/s3492_maximum_containers_on_a_ship/readme.md
@@ -0,0 +1,35 @@
+3492\. Maximum Containers on a Ship
+
+Easy
+
+You are given a positive integer `n` representing an `n x n` cargo deck on a ship. Each cell on the deck can hold one container with a weight of **exactly** `w`.
+
+However, the total weight of all containers, if loaded onto the deck, must not exceed the ship's maximum weight capacity, `maxWeight`.
+
+Return the **maximum** number of containers that can be loaded onto the ship.
+
+**Example 1:**
+
+**Input:** n = 2, w = 3, maxWeight = 15
+
+**Output:** 4
+
+**Explanation:**
+
+The deck has 4 cells, and each container weighs 3. The total weight of loading all containers is 12, which does not exceed `maxWeight`.
+
+**Example 2:**
+
+**Input:** n = 3, w = 5, maxWeight = 20
+
+**Output:** 4
+
+**Explanation:**
+
+The deck has 9 cells, and each container weighs 5. The maximum number of containers that can be loaded without exceeding `maxWeight` is 4.
+
+**Constraints:**
+
+* `1 <= n <= 1000`
+* `1 <= w <= 1000`
+* 1 <= maxWeight <= 109
\ No newline at end of file
diff --git a/src/main/kotlin/g3401_3500/s3493_properties_graph/Solution.kt b/src/main/kotlin/g3401_3500/s3493_properties_graph/Solution.kt
new file mode 100644
index 000000000..01c524885
--- /dev/null
+++ b/src/main/kotlin/g3401_3500/s3493_properties_graph/Solution.kt
@@ -0,0 +1,69 @@
+package g3401_3500.s3493_properties_graph
+
+// #Medium #Array #Hash_Table #Depth_First_Search #Breadth_First_Search #Graph #Union_Find
+// #2025_03_23_Time_45_ms_(100.00%)_Space_65.05_MB_(60.00%)
+
+import java.util.BitSet
+
+class Solution {
+ private lateinit var parent: IntArray
+
+ fun numberOfComponents(properties: Array, k: Int): Int {
+ val al = convertToList(properties)
+ val n = al.size
+ val bs: MutableList = ArrayList(n)
+ for (integers in al) {
+ val bitset = BitSet(101)
+ for (num in integers) {
+ bitset.set(num)
+ }
+ bs.add(bitset)
+ }
+ parent = IntArray(n)
+ for (i in 0..= k) {
+ unionn(i, j)
+ }
+ }
+ }
+ val comps: MutableSet = HashSet()
+ for (i in 0..): MutableList> {
+ val list: MutableList> = ArrayList>()
+ for (row in arr) {
+ val temp: MutableList = ArrayList()
+ for (num in row) {
+ temp.add(num)
+ }
+ list.add(temp)
+ }
+ return list
+ }
+}
diff --git a/src/main/kotlin/g3401_3500/s3493_properties_graph/readme.md b/src/main/kotlin/g3401_3500/s3493_properties_graph/readme.md
new file mode 100644
index 000000000..ddd24b010
--- /dev/null
+++ b/src/main/kotlin/g3401_3500/s3493_properties_graph/readme.md
@@ -0,0 +1,52 @@
+3493\. Properties Graph
+
+Medium
+
+You are given a 2D integer array `properties` having dimensions `n x m` and an integer `k`.
+
+Define a function `intersect(a, b)` that returns the **number of distinct integers** common to both arrays `a` and `b`.
+
+Construct an **undirected** graph where each index `i` corresponds to `properties[i]`. There is an edge between node `i` and node `j` if and only if `intersect(properties[i], properties[j]) >= k`, where `i` and `j` are in the range `[0, n - 1]` and `i != j`.
+
+Return the number of **connected components** in the resulting graph.
+
+**Example 1:**
+
+**Input:** properties = [[1,2],[1,1],[3,4],[4,5],[5,6],[7,7]], k = 1
+
+**Output:** 3
+
+**Explanation:**
+
+The graph formed has 3 connected components:
+
+
+
+**Example 2:**
+
+**Input:** properties = [[1,2,3],[2,3,4],[4,3,5]], k = 2
+
+**Output:** 1
+
+**Explanation:**
+
+The graph formed has 1 connected component:
+
+
+
+**Example 3:**
+
+**Input:** properties = [[1,1],[1,1]], k = 2
+
+**Output:** 2
+
+**Explanation:**
+
+`intersect(properties[0], properties[1]) = 1`, which is less than `k`. This means there is no edge between `properties[0]` and `properties[1]` in the graph.
+
+**Constraints:**
+
+* `1 <= n == properties.length <= 100`
+* `1 <= m == properties[i].length <= 100`
+* `1 <= properties[i][j] <= 100`
+* `1 <= k <= m`
\ No newline at end of file
diff --git a/src/main/kotlin/g3401_3500/s3494_find_the_minimum_amount_of_time_to_brew_potions/Solution.kt b/src/main/kotlin/g3401_3500/s3494_find_the_minimum_amount_of_time_to_brew_potions/Solution.kt
new file mode 100644
index 000000000..c153d93bb
--- /dev/null
+++ b/src/main/kotlin/g3401_3500/s3494_find_the_minimum_amount_of_time_to_brew_potions/Solution.kt
@@ -0,0 +1,25 @@
+package g3401_3500.s3494_find_the_minimum_amount_of_time_to_brew_potions
+
+// #Medium #Array #Simulation #Prefix_Sum #2025_03_23_Time_70_ms_(100.00%)_Space_50.98_MB_(100.00%)
+
+import kotlin.math.max
+
+class Solution {
+ fun minTime(skill: IntArray, mana: IntArray): Long {
+ val endTime = LongArray(skill.size)
+ endTime.fill(0)
+ for (k in mana) {
+ var t: Long = 0
+ var maxDiff: Long = 0
+ for (j in skill.indices) {
+ maxDiff = max(maxDiff, endTime[j] - t)
+ t += skill[j].toLong() * k.toLong()
+ endTime[j] = t
+ }
+ for (j in skill.indices) {
+ endTime[j] += maxDiff
+ }
+ }
+ return endTime[endTime.size - 1]
+ }
+}
diff --git a/src/main/kotlin/g3401_3500/s3494_find_the_minimum_amount_of_time_to_brew_potions/readme.md b/src/main/kotlin/g3401_3500/s3494_find_the_minimum_amount_of_time_to_brew_potions/readme.md
new file mode 100644
index 000000000..fd404460c
--- /dev/null
+++ b/src/main/kotlin/g3401_3500/s3494_find_the_minimum_amount_of_time_to_brew_potions/readme.md
@@ -0,0 +1,53 @@
+3494\. Find the Minimum Amount of Time to Brew Potions
+
+Medium
+
+You are given two integer arrays, `skill` and `mana`, of length `n` and `m`, respectively.
+
+In a laboratory, `n` wizards must brew `m` potions _in order_. Each potion has a mana capacity `mana[j]` and **must** pass through **all** the wizards sequentially to be brewed properly. The time taken by the ith
wizard on the jth
potion is timeij = skill[i] * mana[j]
.
+
+Since the brewing process is delicate, a potion **must** be passed to the next wizard immediately after the current wizard completes their work. This means the timing must be _synchronized_ so that each wizard begins working on a potion **exactly** when it arrives.
+
+Return the **minimum** amount of time required for the potions to be brewed properly.
+
+**Example 1:**
+
+**Input:** skill = [1,5,2,4], mana = [5,1,4,2]
+
+**Output:** 110
+
+**Explanation:**
+
+| Potion Number | Start time | Wizard 0 done by | Wizard 1 done by | Wizard 2 done by | Wizard 3 done by |
+|--------------|-----------|------------------|------------------|------------------|------------------|
+| 0 | 0 | 5 | 30 | 40 | 60 |
+| 1 | 52 | 53 | 58 | 60 | 64 |
+| 2 | 54 | 58 | 78 | 86 | 102 |
+| 3 | 86 | 88 | 98 | 102 | 110 |
+
+As an example for why wizard 0 cannot start working on the 1st potion before time `t = 52`, consider the case where the wizards started preparing the 1st potion at time `t = 50`. At time `t = 58`, wizard 2 is done with the 1st potion, but wizard 3 will still be working on the 0th potion till time `t = 60`.
+
+**Example 2:**
+
+**Input:** skill = [1,1,1], mana = [1,1,1]
+
+**Output:** 5
+
+**Explanation:**
+
+1. Preparation of the 0th potion begins at time `t = 0`, and is completed by time `t = 3`.
+2. Preparation of the 1st potion begins at time `t = 1`, and is completed by time `t = 4`.
+3. Preparation of the 2nd potion begins at time `t = 2`, and is completed by time `t = 5`.
+
+**Example 3:**
+
+**Input:** skill = [1,2,3,4], mana = [1,2]
+
+**Output:** 21
+
+**Constraints:**
+
+* `n == skill.length`
+* `m == mana.length`
+* `1 <= n, m <= 5000`
+* `1 <= mana[i], skill[i] <= 5000`
\ No newline at end of file
diff --git a/src/main/kotlin/g3401_3500/s3495_minimum_operations_to_make_array_elements_zero/Solution.kt b/src/main/kotlin/g3401_3500/s3495_minimum_operations_to_make_array_elements_zero/Solution.kt
new file mode 100644
index 000000000..6efbe7632
--- /dev/null
+++ b/src/main/kotlin/g3401_3500/s3495_minimum_operations_to_make_array_elements_zero/Solution.kt
@@ -0,0 +1,42 @@
+package g3401_3500.s3495_minimum_operations_to_make_array_elements_zero
+
+// #Hard #Array #Math #Bit_Manipulation #2025_03_23_Time_12_ms_(100.00%)_Space_105.09_MB_(100.00%)
+
+class Solution {
+ fun minOperations(queries: Array): Long {
+ var result: Long = 0
+ for (query in queries) {
+ var v: Long = 4
+ var req: Long = 1
+ var totalReq: Long = 0
+ while (query[0] >= v) {
+ v *= 4
+ req++
+ }
+ var group: Long
+ if (query[1] < v) {
+ group = query[1] - query[0] + 1L
+ totalReq += group * req
+ result += (totalReq + 1) / 2
+ continue
+ }
+ group = v - query[0]
+ totalReq += group * req
+ var bottom = v
+ while (true) {
+ v *= 4
+ req++
+ if (query[1] < v) {
+ group = query[1] - bottom + 1
+ totalReq += group * req
+ break
+ }
+ group = v - bottom
+ totalReq += group * req
+ bottom = v
+ }
+ result += (totalReq + 1) / 2
+ }
+ return result
+ }
+}
diff --git a/src/main/kotlin/g3401_3500/s3495_minimum_operations_to_make_array_elements_zero/readme.md b/src/main/kotlin/g3401_3500/s3495_minimum_operations_to_make_array_elements_zero/readme.md
new file mode 100644
index 000000000..5eb5d513b
--- /dev/null
+++ b/src/main/kotlin/g3401_3500/s3495_minimum_operations_to_make_array_elements_zero/readme.md
@@ -0,0 +1,61 @@
+3495\. Minimum Operations to Make Array Elements Zero
+
+Hard
+
+You are given a 2D array `queries`, where `queries[i]` is of the form `[l, r]`. Each `queries[i]` defines an array of integers `nums` consisting of elements ranging from `l` to `r`, both **inclusive**.
+
+In one operation, you can:
+
+* Select two integers `a` and `b` from the array.
+* Replace them with `floor(a / 4)` and `floor(b / 4)`.
+
+Your task is to determine the **minimum** number of operations required to reduce all elements of the array to zero for each query. Return the sum of the results for all queries.
+
+**Example 1:**
+
+**Input:** queries = [[1,2],[2,4]]
+
+**Output:** 3
+
+**Explanation:**
+
+For `queries[0]`:
+
+* The initial array is `nums = [1, 2]`.
+* In the first operation, select `nums[0]` and `nums[1]`. The array becomes `[0, 0]`.
+* The minimum number of operations required is 1.
+
+For `queries[1]`:
+
+* The initial array is `nums = [2, 3, 4]`.
+* In the first operation, select `nums[0]` and `nums[2]`. The array becomes `[0, 3, 1]`.
+* In the second operation, select `nums[1]` and `nums[2]`. The array becomes `[0, 0, 0]`.
+* The minimum number of operations required is 2.
+
+The output is `1 + 2 = 3`.
+
+**Example 2:**
+
+**Input:** queries = [[2,6]]
+
+**Output:** 4
+
+**Explanation:**
+
+For `queries[0]`:
+
+* The initial array is `nums = [2, 3, 4, 5, 6]`.
+* In the first operation, select `nums[0]` and `nums[3]`. The array becomes `[0, 3, 4, 1, 6]`.
+* In the second operation, select `nums[2]` and `nums[4]`. The array becomes `[0, 3, 1, 1, 1]`.
+* In the third operation, select `nums[1]` and `nums[2]`. The array becomes `[0, 0, 0, 1, 1]`.
+* In the fourth operation, select `nums[3]` and `nums[4]`. The array becomes `[0, 0, 0, 0, 0]`.
+* The minimum number of operations required is 4.
+
+The output is 4.
+
+**Constraints:**
+
+* 1 <= queries.length <= 105
+* `queries[i].length == 2`
+* `queries[i] == [l, r]`
+* 1 <= l < r <= 109
\ No newline at end of file
diff --git a/src/test/kotlin/g1101_1200/s1195_fizz_buzz_multithreaded/FizzBuzzTest.kt b/src/test/kotlin/g1101_1200/s1195_fizz_buzz_multithreaded/FizzBuzzTest.kt
index a635eaab1..7dced33c5 100644
--- a/src/test/kotlin/g1101_1200/s1195_fizz_buzz_multithreaded/FizzBuzzTest.kt
+++ b/src/test/kotlin/g1101_1200/s1195_fizz_buzz_multithreaded/FizzBuzzTest.kt
@@ -14,32 +14,32 @@ internal class FizzBuzzTest {
Thread {
try {
fizzBuzz.fizz { fizz[0]++ }
- } catch (e: InterruptedException) {
+ } catch (_: InterruptedException) {
}
}
.start()
Thread {
try {
fizzBuzz.buzz { fizz[0]++ }
- } catch (e: InterruptedException) {
+ } catch (_: InterruptedException) {
}
}
.start()
Thread {
try {
fizzBuzz.fizzbuzz { fizz[0]++ }
- } catch (e: InterruptedException) {
+ } catch (_: InterruptedException) {
}
}
.start()
Thread {
try {
fizzBuzz.number { _: Int -> fizz[0]++ }
- } catch (e: InterruptedException) {
+ } catch (_: InterruptedException) {
}
}
.start()
- TimeUnit.MILLISECONDS.sleep(2000)
+ TimeUnit.MILLISECONDS.sleep(2200)
assertThat(fizz[0] > 0, equalTo(true))
}
@@ -51,28 +51,28 @@ internal class FizzBuzzTest {
Thread {
try {
fizzBuzz.fizz { fizz[0]++ }
- } catch (e: InterruptedException) {
+ } catch (_: InterruptedException) {
}
}
.start()
Thread {
try {
fizzBuzz.buzz { fizz[0]++ }
- } catch (e: InterruptedException) {
+ } catch (_: InterruptedException) {
}
}
.start()
Thread {
try {
fizzBuzz.fizzbuzz { fizz[0]++ }
- } catch (e: InterruptedException) {
+ } catch (_: InterruptedException) {
}
}
.start()
Thread {
try {
fizzBuzz.number { _: Int -> fizz[0]++ }
- } catch (e: InterruptedException) {
+ } catch (_: InterruptedException) {
}
}
.start()
diff --git a/src/test/kotlin/g3401_3500/s3492_maximum_containers_on_a_ship/SolutionTest.kt b/src/test/kotlin/g3401_3500/s3492_maximum_containers_on_a_ship/SolutionTest.kt
new file mode 100644
index 000000000..2a17d9a9c
--- /dev/null
+++ b/src/test/kotlin/g3401_3500/s3492_maximum_containers_on_a_ship/SolutionTest.kt
@@ -0,0 +1,17 @@
+package g3401_3500.s3492_maximum_containers_on_a_ship
+
+import org.hamcrest.CoreMatchers.equalTo
+import org.hamcrest.MatcherAssert.assertThat
+import org.junit.jupiter.api.Test
+
+internal class SolutionTest {
+ @Test
+ fun maxContainers() {
+ assertThat(Solution().maxContainers(2, 3, 15), equalTo(4))
+ }
+
+ @Test
+ fun maxContainers2() {
+ assertThat(Solution().maxContainers(3, 5, 20), equalTo(4))
+ }
+}
diff --git a/src/test/kotlin/g3401_3500/s3493_properties_graph/SolutionTest.kt b/src/test/kotlin/g3401_3500/s3493_properties_graph/SolutionTest.kt
new file mode 100644
index 000000000..d532c7c06
--- /dev/null
+++ b/src/test/kotlin/g3401_3500/s3493_properties_graph/SolutionTest.kt
@@ -0,0 +1,55 @@
+package g3401_3500.s3493_properties_graph
+
+import org.hamcrest.CoreMatchers.equalTo
+import org.hamcrest.MatcherAssert.assertThat
+import org.junit.jupiter.api.Test
+
+internal class SolutionTest {
+ @Test
+ fun numberOfComponents() {
+ assertThat(
+ Solution()
+ .numberOfComponents(
+ arrayOf(
+ intArrayOf(1, 2),
+ intArrayOf(1, 1),
+ intArrayOf(3, 4),
+ intArrayOf(4, 5),
+ intArrayOf(5, 6),
+ intArrayOf(7, 7),
+ ),
+ 1,
+ ),
+ equalTo(3),
+ )
+ }
+
+ @Test
+ fun numberOfComponents2() {
+ assertThat(
+ Solution().numberOfComponents(
+ arrayOf(
+ intArrayOf(1, 2, 3),
+ intArrayOf(2, 3, 4),
+ intArrayOf(4, 3, 5),
+ ),
+ 2,
+ ),
+ equalTo(1),
+ )
+ }
+
+ @Test
+ fun numberOfComponents3() {
+ assertThat(
+ Solution().numberOfComponents(
+ arrayOf(
+ intArrayOf(1, 1),
+ intArrayOf(1, 1),
+ ),
+ 2,
+ ),
+ equalTo(2),
+ )
+ }
+}
diff --git a/src/test/kotlin/g3401_3500/s3494_find_the_minimum_amount_of_time_to_brew_potions/SolutionTest.kt b/src/test/kotlin/g3401_3500/s3494_find_the_minimum_amount_of_time_to_brew_potions/SolutionTest.kt
new file mode 100644
index 000000000..d31a0bf2d
--- /dev/null
+++ b/src/test/kotlin/g3401_3500/s3494_find_the_minimum_amount_of_time_to_brew_potions/SolutionTest.kt
@@ -0,0 +1,31 @@
+package g3401_3500.s3494_find_the_minimum_amount_of_time_to_brew_potions
+
+import org.hamcrest.CoreMatchers.equalTo
+import org.hamcrest.MatcherAssert.assertThat
+import org.junit.jupiter.api.Test
+
+internal class SolutionTest {
+ @Test
+ fun minTime() {
+ assertThat(
+ Solution().minTime(intArrayOf(1, 5, 2, 4), intArrayOf(5, 1, 4, 2)),
+ equalTo(110L),
+ )
+ }
+
+ @Test
+ fun minTime2() {
+ assertThat(
+ Solution().minTime(intArrayOf(1, 1, 1), intArrayOf(1, 1, 1)),
+ equalTo(5L),
+ )
+ }
+
+ @Test
+ fun minTime3() {
+ assertThat(
+ Solution().minTime(intArrayOf(1, 2, 3, 4), intArrayOf(1, 2)),
+ equalTo(21L),
+ )
+ }
+}
diff --git a/src/test/kotlin/g3401_3500/s3495_minimum_operations_to_make_array_elements_zero/SolutionTest.kt b/src/test/kotlin/g3401_3500/s3495_minimum_operations_to_make_array_elements_zero/SolutionTest.kt
new file mode 100644
index 000000000..37d764648
--- /dev/null
+++ b/src/test/kotlin/g3401_3500/s3495_minimum_operations_to_make_array_elements_zero/SolutionTest.kt
@@ -0,0 +1,44 @@
+package g3401_3500.s3495_minimum_operations_to_make_array_elements_zero
+
+import org.hamcrest.CoreMatchers.equalTo
+import org.hamcrest.MatcherAssert.assertThat
+import org.junit.jupiter.api.Test
+
+internal class SolutionTest {
+ @Test
+ fun minOperations() {
+ assertThat(
+ Solution().minOperations(
+ arrayOf(
+ intArrayOf(1, 2),
+ intArrayOf(2, 4),
+ ),
+ ),
+ equalTo(3L),
+ )
+ }
+
+ @Test
+ fun minOperations2() {
+ assertThat(
+ Solution().minOperations(arrayOf(intArrayOf(2, 6))),
+ equalTo(4L),
+ )
+ }
+
+ @Test
+ fun minOperations3() {
+ assertThat(
+ Solution().minOperations(arrayOf(intArrayOf(5, 8))),
+ equalTo(4L),
+ )
+ }
+
+ @Test
+ fun minOperations4() {
+ assertThat(
+ Solution().minOperations(arrayOf(intArrayOf(1, 21))),
+ equalTo(23L),
+ )
+ }
+}