= ArrayList()
+ while (q.isNotEmpty()) {
+ val recipe = q.remove()
+ res.add(recipe)
+ if (adj.containsKey(recipe)) {
+ for (dep in adj[recipe]!!) {
+ indegree[dep] = indegree[dep]!! - 1
+ if (indegree[dep] == 0) {
+ q.add(dep)
+ }
+ }
+ }
+ }
+ return res
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2116_check_if_a_parentheses_string_can_be_valid/readme.md b/src/main/kotlin/g2101_2200/s2116_check_if_a_parentheses_string_can_be_valid/readme.md
new file mode 100644
index 00000000..1b9016b2
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2116_check_if_a_parentheses_string_can_be_valid/readme.md
@@ -0,0 +1,89 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2116\. Check if a Parentheses String Can Be Valid
+
+Medium
+
+A parentheses string is a **non-empty** string consisting only of `'('` and `')'`. It is valid if **any** of the following conditions is **true**:
+
+* It is `()`.
+* It can be written as `AB` (`A` concatenated with `B`), where `A` and `B` are valid parentheses strings.
+* It can be written as `(A)`, where `A` is a valid parentheses string.
+
+You are given a parentheses string `s` and a string `locked`, both of length `n`. `locked` is a binary string consisting only of `'0'`s and `'1'`s. For **each** index `i` of `locked`,
+
+* If `locked[i]` is `'1'`, you **cannot** change `s[i]`.
+* But if `locked[i]` is `'0'`, you **can** change `s[i]` to either `'('` or `')'`.
+
+Return `true` _if you can make `s` a valid parentheses string_. Otherwise, return `false`.
+
+**Example 1:**
+
+
+
+**Input:** s = "))()))", locked = "010100"
+
+**Output:** true
+
+**Explanation:** locked[1] == '1' and locked[3] == '1', so we cannot change s[1] or s[3]. We change s[0] and s[4] to '(' while leaving s[2] and s[5] unchanged to make s valid.
+
+**Example 2:**
+
+**Input:** s = "()()", locked = "0000"
+
+**Output:** true
+
+**Explanation:** We do not need to make any changes because s is already valid.
+
+**Example 3:**
+
+**Input:** s = ")", locked = "0"
+
+**Output:** false
+
+**Explanation:** locked permits us to change s[0]. Changing s[0] to either '(' or ')' will not make s valid.
+
+**Constraints:**
+
+* `n == s.length == locked.length`
+* 1 <= n <= 105
+* `s[i]` is either `'('` or `')'`.
+* `locked[i]` is either `'0'` or `'1'`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun canBeValid(s: String, locked: String): Boolean {
+ if (s.isEmpty()) {
+ return true
+ }
+ if (s.length and 1 > 0) {
+ return false
+ }
+ if (locked.isEmpty()) {
+ return true
+ }
+ var numOfLockedClose = 0
+ var numOfLockedOpen = 0
+ for (i in s.indices) {
+ val countOfChars = i + 1
+ if (s[i] == ')' && locked[i] == '1') {
+ numOfLockedClose++
+ if (numOfLockedClose * 2 > countOfChars) {
+ return false
+ }
+ }
+ val j = s.length - 1 - i
+ if (s[j] == '(' && locked[j] == '1') {
+ numOfLockedOpen++
+ if (numOfLockedOpen * 2 > countOfChars) {
+ return false
+ }
+ }
+ }
+ return true
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2117_abbreviating_the_product_of_a_range/readme.md b/src/main/kotlin/g2101_2200/s2117_abbreviating_the_product_of_a_range/readme.md
new file mode 100644
index 00000000..f541752d
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2117_abbreviating_the_product_of_a_range/readme.md
@@ -0,0 +1,111 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2117\. Abbreviating the Product of a Range
+
+Hard
+
+You are given two positive integers `left` and `right` with `left <= right`. Calculate the **product** of all integers in the **inclusive** range `[left, right]`.
+
+Since the product may be very large, you will **abbreviate** it following these steps:
+
+1. Count all **trailing** zeros in the product and **remove** them. Let us denote this count as `C`.
+ * For example, there are `3` trailing zeros in `1000`, and there are `0` trailing zeros in `546`.
+2. Denote the remaining number of digits in the product as `d`. If `d > 10`, then express the product as `...` where `` denotes the **first** `5` digits of the product, and `` denotes the **last** `5` digits of the product **after** removing all trailing zeros. If `d <= 10`, we keep it unchanged.
+ * For example, we express `1234567654321` as `12345...54321`, but `1234567` is represented as `1234567`.
+3. Finally, represent the product as a **string** `"...eC"`.
+ * For example, `12345678987600000` will be represented as `"12345...89876e5"`.
+
+Return _a string denoting the **abbreviated product** of all integers in the **inclusive** range_ `[left, right]`.
+
+**Example 1:**
+
+**Input:** left = 1, right = 4
+
+**Output:** "24e0"
+
+**Explanation:** The product is 1 × 2 × 3 × 4 = 24.
+
+There are no trailing zeros, so 24 remains the same.
+
+The abbreviation will end with "e0". Since the number of digits is 2, which is less than 10, we do not have to abbreviate it further.
+
+Thus, the final representation is "24e0".
+
+**Example 2:**
+
+**Input:** left = 2, right = 11
+
+**Output:** "399168e2"
+
+**Explanation:** The product is 39916800.
+
+There are 2 trailing zeros, which we remove to get 399168.
+
+The abbreviation will end with "e2". The number of digits after removing the trailing zeros is 6, so we do not abbreviate it further.
+
+Hence, the abbreviated product is "399168e2".
+
+**Example 3:**
+
+**Input:** left = 371, right = 375
+
+**Output:** "7219856259e3"
+
+**Explanation:** The product is 7219856259000.
+
+**Constraints:**
+
+* 1 <= left <= right <= 104
+
+## Solution
+
+```kotlin
+class Solution {
+ fun abbreviateProduct(left: Int, right: Int): String {
+ val threshold0 = 100000000000000L
+ val threshold1 = 10000000000L
+ val threshold2: Long = 100000
+ var curr: Long = 1
+ var i: Int
+ var zerosCount = 0
+ i = left
+ while (i <= right && curr < threshold0) {
+ curr *= i.toLong()
+ while (curr % 10 == 0L) {
+ curr /= 10
+ zerosCount++
+ }
+ i++
+ }
+ if (curr < threshold1) {
+ return String.format("%de%d", curr, zerosCount)
+ }
+ var low = curr % threshold1
+ var high = curr.toDouble()
+ while (high > threshold1) {
+ high /= 10.0
+ }
+ while (i <= right) {
+ low *= i.toLong()
+ high *= i.toDouble()
+ while (low % 10 == 0L) {
+ low /= 10
+ zerosCount++
+ }
+ if (low >= threshold1) {
+ low %= threshold1
+ }
+ while (high > threshold1) {
+ high /= 10.0
+ }
+ i++
+ }
+ while (high >= threshold2) {
+ high /= 10.0
+ }
+ low %= threshold2
+ return String.format("%d...%05de%d", high.toInt(), low, zerosCount)
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2119_a_number_after_a_double_reversal/readme.md b/src/main/kotlin/g2101_2200/s2119_a_number_after_a_double_reversal/readme.md
new file mode 100644
index 00000000..a89a3f4f
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2119_a_number_after_a_double_reversal/readme.md
@@ -0,0 +1,52 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2119\. A Number After a Double Reversal
+
+Easy
+
+**Reversing** an integer means to reverse all its digits.
+
+* For example, reversing `2021` gives `1202`. Reversing `12300` gives `321` as the **leading zeros are not retained**.
+
+Given an integer `num`, **reverse** `num` to get `reversed1`, **then reverse** `reversed1` to get `reversed2`. Return `true` _if_ `reversed2` _equals_ `num`. Otherwise return `false`.
+
+**Example 1:**
+
+**Input:** num = 526
+
+**Output:** true
+
+**Explanation:** Reverse num to get 625, then reverse 625 to get 526, which equals num.
+
+**Example 2:**
+
+**Input:** num = 1800
+
+**Output:** false
+
+**Explanation:** Reverse num to get 81, then reverse 81 to get 18, which does not equal num.
+
+**Example 3:**
+
+**Input:** num = 0
+
+**Output:** true
+
+**Explanation:** Reverse num to get 0, then reverse 0 to get 0, which equals num.
+
+**Constraints:**
+
+* 0 <= num <= 106
+
+## Solution
+
+```kotlin
+class Solution {
+ fun isSameAfterReversals(num: Int): Boolean {
+ return if (num == 0) {
+ true
+ } else num % 10 != 0
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2120_execution_of_all_suffix_instructions_staying_in_a_grid/readme.md b/src/main/kotlin/g2101_2200/s2120_execution_of_all_suffix_instructions_staying_in_a_grid/readme.md
new file mode 100644
index 00000000..0414cdfd
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2120_execution_of_all_suffix_instructions_staying_in_a_grid/readme.md
@@ -0,0 +1,117 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2120\. Execution of All Suffix Instructions Staying in a Grid
+
+Medium
+
+There is an `n x n` grid, with the top-left cell at `(0, 0)` and the bottom-right cell at `(n - 1, n - 1)`. You are given the integer `n` and an integer array `startPos` where startPos = [startrow, startcol] indicates that a robot is initially at cell (startrow, startcol).
+
+You are also given a **0-indexed** string `s` of length `m` where `s[i]` is the ith instruction for the robot: `'L'` (move left), `'R'` (move right), `'U'` (move up), and `'D'` (move down).
+
+The robot can begin executing from any ith instruction in `s`. It executes the instructions one by one towards the end of `s` but it stops if either of these conditions is met:
+
+* The next instruction will move the robot off the grid.
+* There are no more instructions left to execute.
+
+Return _an array_ `answer` _of length_ `m` _where_ `answer[i]` _is **the number of instructions** the robot can execute if the robot **begins executing from** the_ ith _instruction in_ `s`.
+
+**Example 1:**
+
+
+
+**Input:** n = 3, startPos = [0,1], s = "RRDDLU"
+
+**Output:** [1,5,4,3,1,0]
+
+**Explanation:** Starting from startPos and beginning execution from the ith instruction:
+
+- 0th: "**R**RDDLU". Only one instruction "R" can be executed before it moves off the grid.
+
+- 1st: "**RDDLU**". All five instructions can be executed while it stays in the grid and ends at (1, 1).
+
+- 2nd: "**DDLU**". All four instructions can be executed while it stays in the grid and ends at (1, 0).
+
+- 3rd: "**DLU**". All three instructions can be executed while it stays in the grid and ends at (0, 0).
+
+- 4th: "**L**U". Only one instruction "L" can be executed before it moves off the grid.
+
+- 5th: "U". If moving up, it would move off the grid.
+
+**Example 2:**
+
+
+
+**Input:** n = 2, startPos = [1,1], s = "LURD"
+
+**Output:** [4,1,0,0]
+
+**Explanation:**
+
+- 0th: "**LURD**".
+
+- 1st: "**U**RD".
+
+- 2nd: "RD".
+
+- 3rd: "D".
+
+**Example 3:**
+
+
+
+**Input:** n = 1, startPos = [0,0], s = "LRUD"
+
+**Output:** [0,0,0,0]
+
+**Explanation:** No matter which instruction the robot begins execution from, it would move off the grid.
+
+**Constraints:**
+
+* `m == s.length`
+* `1 <= n, m <= 500`
+* `startPos.length == 2`
+* 0 <= startrow, startcol < n
+* `s` consists of `'L'`, `'R'`, `'U'`, and `'D'`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun executeInstructions(n: Int, startPos: IntArray, s: String): IntArray {
+ val answer = IntArray(s.length)
+ for (i in 0 until s.length) {
+ var count = 0
+ var currX = startPos[0]
+ var currY = startPos[1]
+ for (j in i until s.length) {
+ val mv = s[j]
+ if (mv == 'R') {
+ currY++
+ if (currY > n - 1) {
+ break
+ }
+ } else if (mv == 'D') {
+ currX++
+ if (currX > n - 1) {
+ break
+ }
+ } else if (mv == 'L') {
+ currY--
+ if (currY < 0) {
+ break
+ }
+ } else if (mv == 'U') {
+ currX--
+ if (currX < 0) {
+ break
+ }
+ }
+ count++
+ }
+ answer[i] = count
+ }
+ return answer
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2121_intervals_between_identical_elements/readme.md b/src/main/kotlin/g2101_2200/s2121_intervals_between_identical_elements/readme.md
new file mode 100644
index 00000000..7bc22ef5
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2121_intervals_between_identical_elements/readme.md
@@ -0,0 +1,97 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2121\. Intervals Between Identical Elements
+
+Medium
+
+You are given a **0-indexed** array of `n` integers `arr`.
+
+The **interval** between two elements in `arr` is defined as the **absolute difference** between their indices. More formally, the **interval** between `arr[i]` and `arr[j]` is `|i - j|`.
+
+Return _an array_ `intervals` _of length_ `n` _where_ `intervals[i]` _is **the sum of intervals** between_ `arr[i]` _and each element in_ `arr` _with the same value as_ `arr[i]`_._
+
+**Note:** `|x|` is the absolute value of `x`.
+
+**Example 1:**
+
+**Input:** arr = [2,1,3,1,2,3,3]
+
+**Output:** [4,2,7,2,4,4,5]
+
+**Explanation:**
+
+- Index 0: Another 2 is found at index 4. \|0 - 4\| = 4
+
+- Index 1: Another 1 is found at index 3. \|1 - 3\| = 2
+
+- Index 2: Two more 3s are found at indices 5 and 6. \|2 - 5\| + \|2 - 6\| = 7
+
+- Index 3: Another 1 is found at index 1. \|3 - 1\| = 2
+
+- Index 4: Another 2 is found at index 0. \|4 - 0\| = 4
+
+- Index 5: Two more 3s are found at indices 2 and 6. \|5 - 2\| + \|5 - 6\| = 4
+
+- Index 6: Two more 3s are found at indices 2 and 5. \|6 - 2\| + \|6 - 5\| = 5
+
+**Example 2:**
+
+**Input:** arr = [10,5,10,10]
+
+**Output:** [5,0,3,4]
+
+**Explanation:**
+
+- Index 0: Two more 10s are found at indices 2 and 3. \|0 - 2\| + \|0 - 3\| = 5
+
+- Index 1: There is only one 5 in the array, so its sum of intervals to identical elements is 0.
+
+- Index 2: Two more 10s are found at indices 0 and 3. \|2 - 0\| + \|2 - 3\| = 3
+
+- Index 3: Two more 10s are found at indices 0 and 2. \|3 - 0\| + \|3 - 2\| = 4
+
+**Constraints:**
+
+* `n == arr.length`
+* 1 <= n <= 105
+* 1 <= arr[i] <= 105
+
+## Solution
+
+```kotlin
+class Solution {
+ fun getDistances(arr: IntArray): LongArray {
+ val n = arr.size
+ val map: MutableMap> = HashMap()
+ for (i in 0 until n) {
+ var list = map[arr[i]]
+ if (list == null) {
+ list = ArrayList()
+ }
+ list.add(i)
+ map[arr[i]] = list
+ }
+ val ans = LongArray(n)
+ ans.fill(0)
+ for (list in map.values) {
+ var sum: Long = 0
+ val first = list[0]
+ for (i in 1 until list.size) {
+ sum = sum + list[i] - first
+ }
+ ans[first] = sum
+ var prevElements = 0
+ var nextElements = list.size - 2
+ for (i in 1 until list.size) {
+ val diff = list[i] - list[i - 1]
+ sum = sum + diff.toLong() * (prevElements - nextElements)
+ ans[list[i]] = sum
+ prevElements++
+ nextElements--
+ }
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2122_recover_the_original_array/readme.md b/src/main/kotlin/g2101_2200/s2122_recover_the_original_array/readme.md
new file mode 100644
index 00000000..31a05d9c
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2122_recover_the_original_array/readme.md
@@ -0,0 +1,124 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2122\. Recover the Original Array
+
+Hard
+
+Alice had a **0-indexed** array `arr` consisting of `n` **positive** integers. She chose an arbitrary **positive integer** `k` and created two new **0-indexed** integer arrays `lower` and `higher` in the following manner:
+
+1. `lower[i] = arr[i] - k`, for every index `i` where `0 <= i < n`
+2. `higher[i] = arr[i] + k`, for every index `i` where `0 <= i < n`
+
+Unfortunately, Alice lost all three arrays. However, she remembers the integers that were present in the arrays `lower` and `higher`, but not the array each integer belonged to. Help Alice and recover the original array.
+
+Given an array `nums` consisting of `2n` integers, where **exactly** `n` of the integers were present in `lower` and the remaining in `higher`, return _the **original** array_ `arr`. In case the answer is not unique, return _**any** valid array_.
+
+**Note:** The test cases are generated such that there exists **at least one** valid array `arr`.
+
+**Example 1:**
+
+**Input:** nums = [2,10,6,4,8,12]
+
+**Output:** [3,7,11]
+
+**Explanation:**
+
+If arr = [3,7,11] and k = 1, we get lower = [2,6,10] and higher = [4,8,12].
+
+Combining lower and higher gives us [2,6,10,4,8,12], which is a permutation of nums.
+
+Another valid possibility is that arr = [5,7,9] and k = 3. In that case, lower = [2,4,6] and higher = [8,10,12].
+
+**Example 2:**
+
+**Input:** nums = [1,1,3,3]
+
+**Output:** [2,2]
+
+**Explanation:**
+
+If arr = [2,2] and k = 1, we get lower = [1,1] and higher = [3,3].
+
+Combining lower and higher gives us [1,1,3,3], which is equal to nums.
+
+Note that arr cannot be [1,3] because in that case, the only possible way to obtain [1,1,3,3] is with k = 0.
+
+This is invalid since k must be positive.
+
+**Example 3:**
+
+**Input:** nums = [5,435]
+
+**Output:** [220]
+
+**Explanation:** The only possible combination is arr = [220] and k = 215. Using them, we get lower = [5] and higher = [435].
+
+**Constraints:**
+
+* `2 * n == nums.length`
+* `1 <= n <= 1000`
+* 1 <= nums[i] <= 109
+* The test cases are generated such that there exists **at least one** valid array `arr`.
+
+## Solution
+
+```kotlin
+class Solution {
+ private lateinit var res: IntArray
+
+ fun recoverArray(nums: IntArray): IntArray {
+ val n = nums.size
+ nums.sort()
+ val diffs = ArrayList()
+ val smallest = nums[0]
+ for (i in 1 until n) {
+ val k = (nums[i] - smallest) / 2
+ if ((nums[i] - smallest) % 2 == 0 && k != 0) {
+ diffs.add(k)
+ }
+ }
+ for (k in diffs) {
+ if (check(n, k, nums)) {
+ break
+ }
+ }
+ return res
+ }
+
+ private fun check(n: Int, k: Int, nums: IntArray): Boolean {
+ res = IntArray(n / 2)
+ val visited = BooleanArray(n)
+ var lower = 0
+ var higher = 1
+ var count = 0
+ while (lower < n) {
+ if (visited[lower]) {
+ lower++
+ continue
+ }
+ val lowerVal = nums[lower]
+ val higherVal = lowerVal + 2 * k
+ while (higher < n) {
+ if (nums[higher] == higherVal && !visited[higher]) {
+ break
+ }
+ higher++
+ }
+ if (higher == n) {
+ return false
+ }
+ visited[lower] = true
+ visited[higher] = true
+ res[count] = lowerVal + k
+ count++
+ if (count == n / 2) {
+ return true
+ }
+ lower++
+ higher++
+ }
+ return false
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2124_check_if_all_as_appears_before_all_bs/readme.md b/src/main/kotlin/g2101_2200/s2124_check_if_all_as_appears_before_all_bs/readme.md
new file mode 100644
index 00000000..94f5499e
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2124_check_if_all_as_appears_before_all_bs/readme.md
@@ -0,0 +1,74 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2124\. Check if All A's Appears Before All B's
+
+Easy
+
+Given a string `s` consisting of **only** the characters `'a'` and `'b'`, return `true` _if **every**_ `'a'` _appears before **every**_ `'b'` _in the string_. Otherwise, return `false`.
+
+**Example 1:**
+
+**Input:** s = "aaabbb"
+
+**Output:** true
+
+**Explanation:**
+
+The 'a's are at indices 0, 1, and 2, while the 'b's are at indices 3, 4, and 5.
+
+Hence, every 'a' appears before every 'b' and we return true.
+
+**Example 2:**
+
+**Input:** s = "abab"
+
+**Output:** false
+
+**Explanation:**
+
+There is an 'a' at index 2 and a 'b' at index 1.
+
+Hence, not every 'a' appears before every 'b' and we return false.
+
+**Example 3:**
+
+**Input:** s = "bbb"
+
+**Output:** true
+
+**Explanation:** There are no 'a's, hence, every 'a' appears before every 'b' and we return true.
+
+**Constraints:**
+
+* `1 <= s.length <= 100`
+* `s[i]` is either `'a'` or `'b'`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun checkString(s: String): Boolean {
+ var aEndIndex = -1
+ var bStartIndex = -1
+ if (s.length == 1) {
+ return true
+ }
+ for (i in s.length - 1 downTo 0) {
+ if (s[i] == 'a') {
+ aEndIndex = i
+ break
+ }
+ }
+ for (i in 0..s.length - 1) {
+ if (s[i] == 'b') {
+ bStartIndex = i
+ break
+ }
+ }
+ return if (aEndIndex == -1 || bStartIndex == -1) {
+ true
+ } else bStartIndex > aEndIndex
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2125_number_of_laser_beams_in_a_bank/readme.md b/src/main/kotlin/g2101_2200/s2125_number_of_laser_beams_in_a_bank/readme.md
new file mode 100644
index 00000000..04718189
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2125_number_of_laser_beams_in_a_bank/readme.md
@@ -0,0 +1,92 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2125\. Number of Laser Beams in a Bank
+
+Medium
+
+Anti-theft security devices are activated inside a bank. You are given a **0-indexed** binary string array `bank` representing the floor plan of the bank, which is an `m x n` 2D matrix. `bank[i]` represents the ith row, consisting of `'0'`s and `'1'`s. `'0'` means the cell is empty, while`'1'` means the cell has a security device.
+
+There is **one** laser beam between any **two** security devices **if both** conditions are met:
+
+* The two devices are located on two **different rows**: r1 and r2, where r1 < r2.
+* For **each** row `i` where r1 < i < r2, there are **no security devices** in the ith row.
+
+Laser beams are independent, i.e., one beam does not interfere nor join with another.
+
+Return _the total number of laser beams in the bank_.
+
+**Example 1:**
+
+
+
+**Input:** bank = ["011001","000000","010100","001000"]
+
+**Output:** 8
+
+**Explanation:** Between each of the following device pairs, there is one beam. In total, there are 8 beams:
+
+* bank[0][1] -- bank[2][1]
+
+* bank[0][1] -- bank[2][3]
+
+* bank[0][2] -- bank[2][1]
+
+* bank[0][2] -- bank[2][3]
+
+* bank[0][5] -- bank[2][1]
+
+* bank[0][5] -- bank[2][3]
+
+* bank[2][1] -- bank[3][2]
+
+* bank[2][3] -- bank[3][2]
+
+Note that there is no beam between any device on the 0th row with any on the 3rd row.
+
+This is because the 2nd row contains security devices, which breaks the second condition.
+
+**Example 2:**
+
+
+
+**Input:** bank = ["000","111","000"]
+
+**Output:** 0
+
+**Explanation:** There does not exist two devices located on two different rows.
+
+**Constraints:**
+
+* `m == bank.length`
+* `n == bank[i].length`
+* `1 <= m, n <= 500`
+* `bank[i][j]` is either `'0'` or `'1'`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun numberOfBeams(bank: Array): Int {
+ var beam = 0
+ var prev = 0
+ for (s in bank) {
+ var nos = 0
+ for (j in s.toCharArray()) {
+ if (j == '1') {
+ nos++
+ }
+ }
+ if (nos > 0) {
+ if (prev == 0) {
+ prev = nos
+ } else {
+ beam += prev * nos
+ prev = nos
+ }
+ }
+ }
+ return beam
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2126_destroying_asteroids/readme.md b/src/main/kotlin/g2101_2200/s2126_destroying_asteroids/readme.md
new file mode 100644
index 00000000..eb213137
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2126_destroying_asteroids/readme.md
@@ -0,0 +1,94 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2126\. Destroying Asteroids
+
+Medium
+
+You are given an integer `mass`, which represents the original mass of a planet. You are further given an integer array `asteroids`, where `asteroids[i]` is the mass of the ith asteroid.
+
+You can arrange for the planet to collide with the asteroids in **any arbitrary order**. If the mass of the planet is **greater than or equal to** the mass of the asteroid, the asteroid is **destroyed** and the planet **gains** the mass of the asteroid. Otherwise, the planet is destroyed.
+
+Return `true` _if **all** asteroids can be destroyed. Otherwise, return_ `false`_._
+
+**Example 1:**
+
+**Input:** mass = 10, asteroids = [3,9,19,5,21]
+
+**Output:** true
+
+**Explanation:** One way to order the asteroids is [9,19,5,3,21]:
+
+- The planet collides with the asteroid with a mass of 9. New planet mass: 10 + 9 = 19
+
+- The planet collides with the asteroid with a mass of 19. New planet mass: 19 + 19 = 38
+
+- The planet collides with the asteroid with a mass of 5. New planet mass: 38 + 5 = 43
+
+- The planet collides with the asteroid with a mass of 3. New planet mass: 43 + 3 = 46
+
+- The planet collides with the asteroid with a mass of 21. New planet mass: 46 + 21 = 67
+
+All asteroids are destroyed.
+
+**Example 2:**
+
+**Input:** mass = 5, asteroids = [4,9,23,4]
+
+**Output:** false
+
+**Explanation:** The planet cannot ever gain enough mass to destroy the asteroid with a mass of 23.
+
+After the planet destroys the other asteroids, it will have a mass of 5 + 4 + 9 + 4 = 22.
+
+This is less than 23, so a collision would not destroy the last asteroid.
+
+**Constraints:**
+
+* 1 <= mass <= 105
+* 1 <= asteroids.length <= 105
+* 1 <= asteroids[i] <= 105
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ fun asteroidsDestroyed(mass: Int, asteroids: IntArray): Boolean {
+ return helper(mass.toLong(), 0, asteroids)
+ }
+
+ private fun helper(mass: Long, startIndex: Int, asteroids: IntArray): Boolean {
+ var mass = mass
+ var smallOrEqualIndex = partition(mass, startIndex, asteroids)
+ if (smallOrEqualIndex < startIndex) {
+ return false
+ }
+ if (smallOrEqualIndex >= asteroids.size - 1) {
+ return true
+ }
+ for (i in startIndex..smallOrEqualIndex) {
+ mass += asteroids[i].toLong()
+ }
+ return helper(mass, ++smallOrEqualIndex, asteroids)
+ }
+
+ private fun partition(mass: Long, startIndex: Int, asteroids: IntArray): Int {
+ val length = asteroids.size
+ var smallOrEqualIndex = startIndex - 1
+ for (i in startIndex until length) {
+ if (asteroids[i] <= mass) {
+ smallOrEqualIndex++
+ swap(asteroids, i, smallOrEqualIndex)
+ }
+ }
+ return smallOrEqualIndex
+ }
+
+ private fun swap(array: IntArray, i: Int, j: Int) {
+ val tmp = array[i]
+ array[i] = array[j]
+ array[j] = tmp
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2127_maximum_employees_to_be_invited_to_a_meeting/readme.md b/src/main/kotlin/g2101_2200/s2127_maximum_employees_to_be_invited_to_a_meeting/readme.md
new file mode 100644
index 00000000..ec5d19d3
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2127_maximum_employees_to_be_invited_to_a_meeting/readme.md
@@ -0,0 +1,131 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2127\. Maximum Employees to Be Invited to a Meeting
+
+Hard
+
+A company is organizing a meeting and has a list of `n` employees, waiting to be invited. They have arranged for a large **circular** table, capable of seating **any number** of employees.
+
+The employees are numbered from `0` to `n - 1`. Each employee has a **favorite** person and they will attend the meeting **only if** they can sit next to their favorite person at the table. The favorite person of an employee is **not** themself.
+
+Given a **0-indexed** integer array `favorite`, where `favorite[i]` denotes the favorite person of the ith employee, return _the **maximum number of employees** that can be invited to the meeting_.
+
+**Example 1:**
+
+
+
+**Input:** favorite = [2,2,1,2]
+
+**Output:** 3
+
+**Explanation:**
+
+The above figure shows how the company can invite employees 0, 1, and 2, and seat them at the round table.
+
+All employees cannot be invited because employee 2 cannot sit beside employees 0, 1, and 3, simultaneously.
+
+Note that the company can also invite employees 1, 2, and 3, and give them their desired seats.
+
+The maximum number of employees that can be invited to the meeting is 3.
+
+**Example 2:**
+
+**Input:** favorite = [1,2,0]
+
+**Output:** 3
+
+**Explanation:**
+
+Each employee is the favorite person of at least one other employee, and the only way the company can invite them is if they invite every employee.
+
+The seating arrangement will be the same as that in the figure given in example 1:
+
+- Employee 0 will sit between employees 2 and 1.
+
+- Employee 1 will sit between employees 0 and 2.
+
+- Employee 2 will sit between employees 1 and 0.
+
+The maximum number of employees that can be invited to the meeting is 3.
+
+**Example 3:**
+
+
+
+**Input:** favorite = [3,0,1,4,1]
+
+**Output:** 4
+
+**Explanation:**
+
+The above figure shows how the company will invite employees 0, 1, 3, and 4, and seat them at the round table.
+
+Employee 2 cannot be invited because the two spots next to their favorite employee 1 are taken.
+
+So the company leaves them out of the meeting. \
+
+The maximum number of employees that can be invited to the meeting is 4.
+
+**Constraints:**
+
+* `n == favorite.length`
+* 2 <= n <= 105
+* `0 <= favorite[i] <= n - 1`
+* `favorite[i] != i`
+
+## Solution
+
+```kotlin
+import java.util.LinkedList
+import java.util.Queue
+
+class Solution {
+ fun maximumInvitations(favorite: IntArray): Int {
+ if (favorite.isEmpty()) return 0
+ val n = favorite.size
+ var cycle = 0
+ var cycleDepth = 0
+ val indegree = IntArray(n)
+ val depth = IntArray(n)
+ val visited = BooleanArray(n)
+ val q: Queue = LinkedList()
+ for (i in 0 until n) {
+ indegree[favorite[i]]++
+ depth[i] = 1
+ }
+ for (i in 0 until n) {
+ if (indegree[i] == 0) {
+ q.add(i)
+ visited[i] = true
+ }
+ }
+ while (q.isNotEmpty()) {
+ val curr = q.poll()
+ val next = favorite[curr]
+ indegree[next]--
+ if (indegree[next] == 0) {
+ q.add(next)
+ visited[next] = true
+ }
+ depth[next] = depth[curr] + 1
+ }
+ for (i in 0 until n) {
+ if (visited[i]) continue
+ var j = i
+ var count = 0
+ while (!visited[j]) {
+ visited[j] = true
+ j = favorite[j]
+ count++
+ }
+ if (count > 2) {
+ cycle = Math.max(cycle, count)
+ } else {
+ cycleDepth += depth[i] + depth[favorite[i]]
+ }
+ }
+ return Math.max(cycle, cycleDepth)
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2129_capitalize_the_title/readme.md b/src/main/kotlin/g2101_2200/s2129_capitalize_the_title/readme.md
new file mode 100644
index 00000000..c6c0c53f
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2129_capitalize_the_title/readme.md
@@ -0,0 +1,79 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2129\. Capitalize the Title
+
+Easy
+
+You are given a string `title` consisting of one or more words separated by a single space, where each word consists of English letters. **Capitalize** the string by changing the capitalization of each word such that:
+
+* If the length of the word is `1` or `2` letters, change all letters to lowercase.
+* Otherwise, change the first letter to uppercase and the remaining letters to lowercase.
+
+Return _the **capitalized**_ `title`.
+
+**Example 1:**
+
+**Input:** title = "capiTalIze tHe titLe"
+
+**Output:** "Capitalize The Title"
+
+**Explanation:** Since all the words have a length of at least 3, the first letter of each word is uppercase, and the remaining letters are lowercase.
+
+**Example 2:**
+
+**Input:** title = "First leTTeR of EACH Word"
+
+**Output:** "First Letter of Each Word"
+
+**Explanation:**
+
+The word "of" has length 2, so it is all lowercase.
+
+The remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.
+
+**Example 3:**
+
+**Input:** title = "i lOve leetcode"
+
+**Output:** "i Love Leetcode"
+
+**Explanation:**
+
+The word "i" has length 1, so it is lowercase.
+
+The remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.
+
+**Constraints:**
+
+* `1 <= title.length <= 100`
+* `title` consists of words separated by a single space without any leading or trailing spaces.
+* Each word consists of uppercase and lowercase English letters and is **non-empty**.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun capitalizeTitle(title: String): String {
+ val sb = StringBuilder()
+ var i = 0
+ var j = 0
+ while (i < title.length) {
+ while (j < title.length && title[j] != ' ') {
+ sb.append(title[j].lowercaseChar())
+ j++
+ }
+ val len = j - i
+ if (len > 2) {
+ sb.setCharAt(i, title[i].uppercaseChar())
+ }
+ if (j == title.length) {
+ break
+ }
+ sb.append(title[j])
+ i = ++j
+ }
+ return sb.toString()
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2130_maximum_twin_sum_of_a_linked_list/readme.md b/src/main/kotlin/g2101_2200/s2130_maximum_twin_sum_of_a_linked_list/readme.md
new file mode 100644
index 00000000..cc6446c7
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2130_maximum_twin_sum_of_a_linked_list/readme.md
@@ -0,0 +1,118 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2130\. Maximum Twin Sum of a Linked List
+
+Medium
+
+In a linked list of size `n`, where `n` is **even**, the ith node (**0-indexed**) of the linked list is known as the **twin** of the (n-1-i)th node, if `0 <= i <= (n / 2) - 1`.
+
+* For example, if `n = 4`, then node `0` is the twin of node `3`, and node `1` is the twin of node `2`. These are the only nodes with twins for `n = 4`.
+
+The **twin sum** is defined as the sum of a node and its twin.
+
+Given the `head` of a linked list with even length, return _the **maximum twin sum** of the linked list_.
+
+**Example 1:**
+
+
+
+**Input:** head = [5,4,2,1]
+
+**Output:** 6
+
+**Explanation:**
+
+Nodes 0 and 1 are the twins of nodes 3 and 2, respectively. All have twin sum = 6.
+
+There are no other nodes with twins in the linked list.
+
+Thus, the maximum twin sum of the linked list is 6.
+
+**Example 2:**
+
+
+
+**Input:** head = [4,2,2,3]
+
+**Output:** 7
+
+**Explanation:**
+
+The nodes with twins present in this linked list are:
+
+- Node 0 is the twin of node 3 having a twin sum of 4 + 3 = 7.
+
+- Node 1 is the twin of node 2 having a twin sum of 2 + 2 = 4.
+
+Thus, the maximum twin sum of the linked list is max(7, 4) = 7.
+
+**Example 3:**
+
+
+
+**Input:** head = [1,100000]
+
+**Output:** 100001
+
+**Explanation:**
+
+There is only one node with a twin in the linked list having twin sum of 1 + 100000 = 100001.
+
+**Constraints:**
+
+* The number of nodes in the list is an **even** integer in the range [2, 105].
+* 1 <= Node.val <= 105
+
+## Solution
+
+```kotlin
+import com_github_leetcode.ListNode
+
+/*
+ * Example:
+ * var li = ListNode(5)
+ * var v = li.`val`
+ * Definition for singly-linked list.
+ * class ListNode(var `val`: Int) {
+ * var next: ListNode? = null
+ * }
+ */
+class Solution {
+ fun pairSum(head: ListNode?): Int {
+ if (head == null) {
+ return 0
+ }
+ var maxSum = Int.MIN_VALUE
+ var slow = head
+ var fast = head
+ while (fast != null && fast.next != null) {
+ slow = slow!!.next
+ fast = fast.next!!.next
+ }
+ if (slow!!.next == null) {
+ return head.`val` + slow.`val`
+ }
+ var tail = head
+ var pivot = reverse(slow)
+ while (pivot != null) {
+ maxSum = Math.max(maxSum, tail!!.`val` + pivot.`val`)
+ tail = tail.next
+ pivot = pivot.next
+ }
+ return maxSum
+ }
+
+ private fun reverse(head: ListNode?): ListNode? {
+ var tail = head
+ var prev: ListNode? = null
+ while (tail != null) {
+ val temp = tail.next
+ tail.next = prev
+ prev = tail
+ tail = temp
+ }
+ return prev
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2131_longest_palindrome_by_concatenating_two_letter_words/readme.md b/src/main/kotlin/g2101_2200/s2131_longest_palindrome_by_concatenating_two_letter_words/readme.md
new file mode 100644
index 00000000..c58efccd
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2131_longest_palindrome_by_concatenating_two_letter_words/readme.md
@@ -0,0 +1,83 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2131\. Longest Palindrome by Concatenating Two Letter Words
+
+Medium
+
+You are given an array of strings `words`. Each element of `words` consists of **two** lowercase English letters.
+
+Create the **longest possible palindrome** by selecting some elements from `words` and concatenating them in **any order**. Each element can be selected **at most once**.
+
+Return _the **length** of the longest palindrome that you can create_. If it is impossible to create any palindrome, return `0`.
+
+A **palindrome** is a string that reads the same forward and backward.
+
+**Example 1:**
+
+**Input:** words = ["lc","cl","gg"]
+
+**Output:** 6
+
+**Explanation:** One longest palindrome is "lc" + "gg" + "cl" = "lcggcl", of length 6. Note that "clgglc" is another longest palindrome that can be created.
+
+**Example 2:**
+
+**Input:** words = ["ab","ty","yt","lc","cl","ab"]
+
+**Output:** 8
+
+**Explanation:** One longest palindrome is "ty" + "lc" + "cl" + "yt" = "tylcclyt", of length 8. Note that "lcyttycl" is another longest palindrome that can be created.
+
+**Example 3:**
+
+**Input:** words = ["cc","ll","xx"]
+
+**Output:** 2
+
+**Explanation:** One longest palindrome is "cc", of length 2. Note that "ll" is another longest palindrome that can be created, and so is "xx".
+
+**Constraints:**
+
+* 1 <= words.length <= 105
+* `words[i].length == 2`
+* `words[i]` consists of lowercase English letters.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun longestPalindrome(words: Array): Int {
+ val counter: MutableMap = HashMap()
+ for (word in words) {
+ counter[word] = counter.getOrDefault(word, 0) + 1
+ }
+ var pairPalindrome = 0
+ var selfPalindrome = 0
+ for ((key, count1) in counter) {
+ if (isPalindrome(key)) {
+ selfPalindrome += if (count1 % 2 == 1 && selfPalindrome % 2 == 0) {
+ count1
+ } else {
+ count1 - count1 % 2
+ }
+ } else {
+ val palindrome = palindrome(key)
+ val count = counter[palindrome]
+ if (count != null) {
+ pairPalindrome += Math.min(count, count1)
+ }
+ }
+ }
+ return 2 * (selfPalindrome + pairPalindrome)
+ }
+
+ private fun isPalindrome(word: String): Boolean {
+ return word[1] == word[0]
+ }
+
+ private fun palindrome(word: String): String {
+ return java.lang.String.valueOf(charArrayOf(word[1], word[0]))
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2132_stamping_the_grid/readme.md b/src/main/kotlin/g2101_2200/s2132_stamping_the_grid/readme.md
new file mode 100644
index 00000000..cad0b688
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2132_stamping_the_grid/readme.md
@@ -0,0 +1,112 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2132\. Stamping the Grid
+
+Hard
+
+You are given an `m x n` binary matrix `grid` where each cell is either `0` (empty) or `1` (occupied).
+
+You are then given stamps of size `stampHeight x stampWidth`. We want to fit the stamps such that they follow the given **restrictions** and **requirements**:
+
+1. Cover all the **empty** cells.
+2. Do not cover any of the **occupied** cells.
+3. We can put as **many** stamps as we want.
+4. Stamps can **overlap** with each other.
+5. Stamps are not allowed to be **rotated**.
+6. Stamps must stay completely **inside** the grid.
+
+Return `true` _if it is possible to fit the stamps while following the given restrictions and requirements. Otherwise, return_ `false`.
+
+**Example 1:**
+
+
+
+**Input:** grid = \[\[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0]], stampHeight = 4, stampWidth = 3
+
+**Output:** true
+
+**Explanation:** We have two overlapping stamps (labeled 1 and 2 in the image) that are able to cover all the empty cells.
+
+**Example 2:**
+
+
+
+**Input:** grid = \[\[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]], stampHeight = 2, stampWidth = 2
+
+**Output:** false
+
+**Explanation:** There is no way to fit the stamps onto all the empty cells without the stamps going outside the grid.
+
+**Constraints:**
+
+* `m == grid.length`
+* `n == grid[r].length`
+* 1 <= m, n <= 105
+* 1 <= m * n <= 2 * 105
+* `grid[r][c]` is either `0` or `1`.
+* 1 <= stampHeight, stampWidth <= 105
+
+## Solution
+
+```kotlin
+class Solution {
+ private fun canPaved(grid: Array, `is`: Int, js: Int, ie: Int, je: Int): Boolean {
+ for (i in `is`..ie) {
+ for (j in js..je) {
+ if (grid[i][j] == 1) {
+ return true
+ }
+ }
+ }
+ return false
+ }
+
+ fun possibleToStamp(grid: Array, h: Int, w: Int): Boolean {
+ val rl = grid[0].size
+ for (i in grid.indices) {
+ val row = grid[i]
+ var prev = -1
+ for (j in row.indices) {
+ if (row[j] == 0) {
+ if (j + 1 < rl && row[j + 1] == 1 && j - w + 1 >= 0 &&
+ i + 1 < grid.size && grid[i + 1][j] == 1 && i - h + 1 >= 0 && canPaved(
+ grid,
+ i - h + 1,
+ j - w + 1,
+ i,
+ j
+ )
+ ) {
+ return false
+ }
+ continue
+ }
+ if (j - prev in 2..w) {
+ return false
+ }
+ prev = j
+ }
+ if (row.size - prev in 2..w) {
+ return false
+ }
+ }
+ for (i in 0 until rl) {
+ var prev = -1
+ for (j in grid.indices) {
+ if (grid[j][i] == 0) {
+ continue
+ }
+ if (j - prev in 2..h) {
+ return false
+ }
+ prev = j
+ }
+ if (grid.size - prev in 2..h) {
+ return false
+ }
+ }
+ return true
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2133_check_if_every_row_and_column_contains_all_numbers/readme.md b/src/main/kotlin/g2101_2200/s2133_check_if_every_row_and_column_contains_all_numbers/readme.md
new file mode 100644
index 00000000..e8fe9b34
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2133_check_if_every_row_and_column_contains_all_numbers/readme.md
@@ -0,0 +1,66 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2133\. Check if Every Row and Column Contains All Numbers
+
+Easy
+
+An `n x n` matrix is **valid** if every row and every column contains **all** the integers from `1` to `n` (**inclusive**).
+
+Given an `n x n` integer matrix `matrix`, return `true` _if the matrix is **valid**._ Otherwise, return `false`.
+
+**Example 1:**
+
+
+
+**Input:** matrix = \[\[1,2,3],[3,1,2],[2,3,1]]
+
+**Output:** true
+
+**Explanation:** In this case, n = 3, and every row and column contains the numbers 1, 2, and 3. Hence, we return true.
+
+**Example 2:**
+
+
+
+**Input:** matrix = \[\[1,1,1],[1,2,3],[1,2,3]]
+
+**Output:** false
+
+**Explanation:** In this case, n = 3, but the first row and the first column do not contain the numbers 2 or 3. Hence, we return false.
+
+**Constraints:**
+
+* `n == matrix.length == matrix[i].length`
+* `1 <= n <= 100`
+* `1 <= matrix[i][j] <= n`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun checkValid(matrix: Array): Boolean {
+ val n = matrix.size
+ val set: MutableSet = HashSet()
+ for (ints in matrix) {
+ for (anInt in ints) {
+ set.add(anInt)
+ }
+ if (set.size != n) {
+ return false
+ }
+ set.clear()
+ }
+ for (i in matrix[0].indices) {
+ for (ints in matrix) {
+ set.add(ints[i])
+ }
+ if (set.size != n) {
+ return false
+ }
+ set.clear()
+ }
+ return true
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2134_minimum_swaps_to_group_all_1s_together_ii/readme.md b/src/main/kotlin/g2101_2200/s2134_minimum_swaps_to_group_all_1s_together_ii/readme.md
new file mode 100644
index 00000000..a99f8c0a
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2134_minimum_swaps_to_group_all_1s_together_ii/readme.md
@@ -0,0 +1,102 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2134\. Minimum Swaps to Group All 1's Together II
+
+Medium
+
+A **swap** is defined as taking two **distinct** positions in an array and swapping the values in them.
+
+A **circular** array is defined as an array where we consider the **first** element and the **last** element to be **adjacent**.
+
+Given a **binary** **circular** array `nums`, return _the minimum number of swaps required to group all_ `1`_'s present in the array together at **any location**_.
+
+**Example 1:**
+
+**Input:** nums = [0,1,0,1,1,0,0]
+
+**Output:** 1
+
+**Explanation:** Here are a few of the ways to group all the 1's together:
+
+[0,0,1,1,1,0,0] using 1 swap.
+
+[0,1,1,1,0,0,0] using 1 swap.
+
+[1,1,0,0,0,0,1] using 2 swaps (using the circular property of the array).
+
+There is no way to group all 1's together with 0 swaps.
+
+Thus, the minimum number of swaps required is 1.
+
+**Example 2:**
+
+**Input:** nums = [0,1,1,1,0,0,1,1,0]
+
+**Output:** 2
+
+**Explanation:** Here are a few of the ways to group all the 1's together:
+
+[1,1,1,0,0,0,0,1,1] using 2 swaps (using the circular property of the array).
+
+[1,1,1,1,1,0,0,0,0] using 2 swaps.
+
+There is no way to group all 1's together with 0 or 1 swaps.
+
+Thus, the minimum number of swaps required is 2.
+
+**Example 3:**
+
+**Input:** nums = [1,1,0,0,1]
+
+**Output:** 0
+
+**Explanation:** All the 1's are already grouped together due to the circular property of the array.
+
+Thus, the minimum number of swaps required is 0.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* `nums[i]` is either `0` or `1`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minSwaps(nums: IntArray): Int {
+ val l = nums.size
+ val ones = IntArray(l)
+ ones[0] = if (nums[0] == 1) 1 else 0
+ for (i in 1 until l) {
+ if (nums[i] == 1) {
+ ones[i] = ones[i - 1] + 1
+ } else {
+ ones[i] = ones[i - 1]
+ }
+ }
+ if (ones[l - 1] == l || ones[l - 1] == 0) {
+ return 0
+ }
+ val ws = ones[l - 1]
+ var minSwaps = Int.MAX_VALUE
+ var si = 0
+ var ei: Int
+ while (si < nums.size) {
+ ei = (si + ws - 1) % l
+ var totalones: Int
+ totalones = if (ei >= si) {
+ ones[ei] - if (si == 0) 0 else ones[si - 1]
+ } else {
+ ones[ei] + (ones[l - 1] - ones[si - 1])
+ }
+ val swapsreq = ws - totalones
+ if (swapsreq < minSwaps) {
+ minSwaps = swapsreq
+ }
+ si++
+ }
+ return minSwaps
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2135_count_words_obtained_after_adding_a_letter/readme.md b/src/main/kotlin/g2101_2200/s2135_count_words_obtained_after_adding_a_letter/readme.md
new file mode 100644
index 00000000..7a953ad5
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2135_count_words_obtained_after_adding_a_letter/readme.md
@@ -0,0 +1,125 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2135\. Count Words Obtained After Adding a Letter
+
+Medium
+
+You are given two **0-indexed** arrays of strings `startWords` and `targetWords`. Each string consists of **lowercase English letters** only.
+
+For each string in `targetWords`, check if it is possible to choose a string from `startWords` and perform a **conversion operation** on it to be equal to that from `targetWords`.
+
+The **conversion operation** is described in the following two steps:
+
+1. **Append** any lowercase letter that is **not present** in the string to its end.
+ * For example, if the string is `"abc"`, the letters `'d'`, `'e'`, or `'y'` can be added to it, but not `'a'`. If `'d'` is added, the resulting string will be `"abcd"`.
+2. **Rearrange** the letters of the new string in **any** arbitrary order.
+ * For example, `"abcd"` can be rearranged to `"acbd"`, `"bacd"`, `"cbda"`, and so on. Note that it can also be rearranged to `"abcd"` itself.
+
+Return _the **number of strings** in_ `targetWords` _that can be obtained by performing the operations on **any** string of_ `startWords`.
+
+**Note** that you will only be verifying if the string in `targetWords` can be obtained from a string in `startWords` by performing the operations. The strings in `startWords` **do not** actually change during this process.
+
+**Example 1:**
+
+**Input:** startWords = ["ant","act","tack"], targetWords = ["tack","act","acti"]
+
+**Output:** 2
+
+**Explanation:**
+
+- In order to form targetWords[0] = "tack", we use startWords[1] = "act", append 'k' to it, and rearrange "actk" to "tack".
+
+- There is no string in startWords that can be used to obtain targetWords[1] = "act".
+
+Note that "act" does exist in startWords, but we **must** append one letter to the string before rearranging it.
+
+- In order to form targetWords[2] = "acti", we use startWords[1] = "act", append 'i' to it, and rearrange "acti" to "acti" itself.
+
+**Example 2:**
+
+**Input:** startWords = ["ab","a"], targetWords = ["abc","abcd"]
+
+**Output:** 1
+
+**Explanation:**
+
+- In order to form targetWords[0] = "abc", we use startWords[0] = "ab", add 'c' to it, and rearrange it to "abc".
+
+- There is no string in startWords that can be used to obtain targetWords[1] = "abcd".
+
+**Constraints:**
+
+* 1 <= startWords.length, targetWords.length <= 5 * 104
+* `1 <= startWords[i].length, targetWords[j].length <= 26`
+* Each string of `startWords` and `targetWords` consists of lowercase English letters only.
+* No letter occurs more than once in any string of `startWords` or `targetWords`.
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ private lateinit var set: MutableSet
+
+ private fun preprocess(words: Array) {
+ set = HashSet()
+ for (word in words) {
+ val bitMap = getBitMap(word)
+ set.add(bitMap)
+ }
+ }
+
+ private fun matches(bitMap: Int): Boolean {
+ return set.contains(bitMap)
+ }
+
+ private fun getBitMap(word: String): Int {
+ var result = 0
+ for (element in word) {
+ val position = element.code - 'a'.code
+ result = result or (1 shl position)
+ }
+ return result
+ }
+
+ private fun addBit(bitMap: Int, c: Char): Int {
+ var bitMap = bitMap
+ val position = c.code - 'a'.code
+ bitMap = bitMap or (1 shl position)
+ return bitMap
+ }
+
+ private fun removeBit(bitMap: Int, c: Char): Int {
+ var bitMap = bitMap
+ val position = c.code - 'a'.code
+ bitMap = bitMap and (1 shl position).inv()
+ return bitMap
+ }
+
+ fun wordCount(startWords: Array, targetWords: Array): Int {
+ if (startWords.isEmpty()) {
+ return 0
+ }
+ if (targetWords.isEmpty()) {
+ return 0
+ }
+ preprocess(startWords)
+ var count = 0
+ for (word in targetWords) {
+ var bitMap = getBitMap(word)
+ for (i in word.indices) {
+ bitMap = removeBit(bitMap, word[i])
+ if (i > 0) {
+ bitMap = addBit(bitMap, word[i - 1])
+ }
+ if (matches(bitMap)) {
+ count++
+ break
+ }
+ }
+ }
+ return count
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2136_earliest_possible_day_of_full_bloom/readme.md b/src/main/kotlin/g2101_2200/s2136_earliest_possible_day_of_full_bloom/readme.md
new file mode 100644
index 00000000..c2e5ced2
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2136_earliest_possible_day_of_full_bloom/readme.md
@@ -0,0 +1,108 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2136\. Earliest Possible Day of Full Bloom
+
+Hard
+
+You have `n` flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two **0-indexed** integer arrays `plantTime` and `growTime`, of length `n` each:
+
+* `plantTime[i]` is the number of **full days** it takes you to **plant** the ith seed. Every day, you can work on planting exactly one seed. You **do not** have to work on planting the same seed on consecutive days, but the planting of a seed is not complete **until** you have worked `plantTime[i]` days on planting it in total.
+* `growTime[i]` is the number of **full days** it takes the ith seed to grow after being completely planted. **After** the last day of its growth, the flower **blooms** and stays bloomed forever.
+
+From the beginning of day `0`, you can plant the seeds in **any** order.
+
+Return _the **earliest** possible day where **all** seeds are blooming_.
+
+**Example 1:**
+
+
+
+**Input:** plantTime = [1,4,3], growTime = [2,3,1]
+
+**Output:** 9
+
+**Explanation:** The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms.
+
+One optimal way is:
+
+On day 0, plant the 0th seed. The seed grows for 2 full days and blooms on day 3.
+
+On days 1, 2, 3, and 4, plant the 1st seed. The seed grows for 3 full days and blooms on day 8.
+
+On days 5, 6, and 7, plant the 2nd seed. The seed grows for 1 full day and blooms on day 9.
+
+Thus, on day 9, all the seeds are blooming.
+
+**Example 2:**
+
+
+
+**Input:** plantTime = [1,2,3,2], growTime = [2,1,2,1]
+
+**Output:** 9
+
+**Explanation:** The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms.
+
+One optimal way is:
+
+On day 1, plant the 0th seed. The seed grows for 2 full days and blooms on day 4.
+
+On days 0 and 3, plant the 1st seed. The seed grows for 1 full day and blooms on day 5.
+
+On days 2, 4, and 5, plant the 2nd seed. The seed grows for 2 full days and blooms on day 8.
+
+On days 6 and 7, plant the 3rd seed. The seed grows for 1 full day and blooms on day 9.
+
+Thus, on day 9, all the seeds are blooming.
+
+**Example 3:**
+
+**Input:** plantTime = [1], growTime = [1]
+
+**Output:** 2
+
+**Explanation:** On day 0, plant the 0th seed. The seed grows for 1 full day and blooms on day 2.
+
+Thus, on day 2, all the seeds are blooming.
+
+**Constraints:**
+
+* `n == plantTime.length == growTime.length`
+* 1 <= n <= 105
+* 1 <= plantTime[i], growTime[i] <= 104
+
+## Solution
+
+```kotlin
+import java.util.Arrays
+import java.util.Collections
+
+class Solution {
+ fun earliestFullBloom(plantTime: IntArray, growTime: IntArray): Int {
+ val n = plantTime.size
+ if (n == 1) {
+ return plantTime[0] + growTime[0]
+ }
+ val arr = arrayOfNulls(n)
+ for (i in 0 until n) {
+ arr[i] = Seed(plantTime[i], growTime[i])
+ }
+ Arrays.sort(arr, Collections.reverseOrder())
+ var ans = arr[0]!!.plantTime + arr[0]!!.growTime
+ var lastPlantDay = arr[0]!!.plantTime
+ for (i in 1 until n) {
+ val currBloomDay = lastPlantDay + arr[i]!!.plantTime + arr[i]!!.growTime
+ ans = Math.max(ans, currBloomDay)
+ lastPlantDay += arr[i]!!.plantTime
+ }
+ return ans
+ }
+
+ internal class Seed(var plantTime: Int, var growTime: Int) : Comparable {
+ override fun compareTo(other: Seed): Int {
+ return growTime - other.growTime
+ }
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2138_divide_a_string_into_groups_of_size_k/readme.md b/src/main/kotlin/g2101_2200/s2138_divide_a_string_into_groups_of_size_k/readme.md
new file mode 100644
index 00000000..7d9a4fe4
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2138_divide_a_string_into_groups_of_size_k/readme.md
@@ -0,0 +1,90 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2138\. Divide a String Into Groups of Size k
+
+Easy
+
+A string `s` can be partitioned into groups of size `k` using the following procedure:
+
+* The first group consists of the first `k` characters of the string, the second group consists of the next `k` characters of the string, and so on. Each character can be a part of **exactly one** group.
+* For the last group, if the string **does not** have `k` characters remaining, a character `fill` is used to complete the group.
+
+Note that the partition is done so that after removing the `fill` character from the last group (if it exists) and concatenating all the groups in order, the resultant string should be `s`.
+
+Given the string `s`, the size of each group `k` and the character `fill`, return _a string array denoting the **composition of every group**_ `s` _has been divided into, using the above procedure_.
+
+**Example 1:**
+
+**Input:** s = "abcdefghi", k = 3, fill = "x"
+
+**Output:** ["abc","def","ghi"]
+
+**Explanation:**
+
+The first 3 characters "abc" form the first group.
+
+The next 3 characters "def" form the second group.
+
+The last 3 characters "ghi" form the third group.
+
+Since all groups can be completely filled by characters from the string, we do not need to use fill.
+
+Thus, the groups formed are "abc", "def", and "ghi".
+
+**Example 2:**
+
+**Input:** s = "abcdefghij", k = 3, fill = "x"
+
+**Output:** ["abc","def","ghi","jxx"]
+
+**Explanation:**
+
+Similar to the previous example, we are forming the first three groups "abc", "def", and "ghi".
+
+For the last group, we can only use the character 'j' from the string.
+
+To complete this group, we add 'x' twice. Thus, the 4 groups formed are "abc", "def", "ghi", and "jxx".
+
+**Constraints:**
+
+* `1 <= s.length <= 100`
+* `s` consists of lowercase English letters only.
+* `1 <= k <= 100`
+* `fill` is a lowercase English letter.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun divideString(s: String, k: Int, fill: Char): Array {
+ val ans = arrayOfNulls(if (s.length % k != 0) s.length / k + 1 else s.length / k)
+ var t = k
+ val str: MutableList = ArrayList()
+ val sb = StringBuilder()
+ var i = 0
+ while (i < s.length) {
+ if (t > 0) {
+ sb.append(s[i])
+ t--
+ } else {
+ t = k
+ str.add(sb.toString())
+ sb.setLength(0)
+ i--
+ }
+ i++
+ }
+ if (t > 0) {
+ while (t-- > 0) {
+ sb.append(fill)
+ }
+ }
+ str.add(sb.toString())
+ for (j in str.indices) {
+ ans[j] = str[j]
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2139_minimum_moves_to_reach_target_score/readme.md b/src/main/kotlin/g2101_2200/s2139_minimum_moves_to_reach_target_score/readme.md
new file mode 100644
index 00000000..5e455b80
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2139_minimum_moves_to_reach_target_score/readme.md
@@ -0,0 +1,92 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2139\. Minimum Moves to Reach Target Score
+
+Medium
+
+You are playing a game with integers. You start with the integer `1` and you want to reach the integer `target`.
+
+In one move, you can either:
+
+* **Increment** the current integer by one (i.e., `x = x + 1`).
+* **Double** the current integer (i.e., `x = 2 * x`).
+
+You can use the **increment** operation **any** number of times, however, you can only use the **double** operation **at most** `maxDoubles` times.
+
+Given the two integers `target` and `maxDoubles`, return _the minimum number of moves needed to reach_ `target` _starting with_ `1`.
+
+**Example 1:**
+
+**Input:** target = 5, maxDoubles = 0
+
+**Output:** 4
+
+**Explanation:** Keep incrementing by 1 until you reach target.
+
+**Example 2:**
+
+**Input:** target = 19, maxDoubles = 2
+
+**Output:** 7
+
+**Explanation:** Initially, x = 1
+
+Increment 3 times so x = 4
+
+Double once so x = 8
+
+Increment once so x = 9
+
+Double again so x = 18
+
+Increment once so x = 19
+
+**Example 3:**
+
+**Input:** target = 10, maxDoubles = 4
+
+**Output:** 4
+
+**Explanation:** Initially, x = 1
+
+Increment once so x = 2
+
+Double once so x = 4
+
+Increment once so x = 5
+
+Double again so x = 10
+
+**Constraints:**
+
+* 1 <= target <= 109
+* `0 <= maxDoubles <= 100`
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ fun minMoves(target: Int, maxDoubles: Int): Int {
+ var target = target
+ var maxDoubles = maxDoubles
+ var count = 0
+ while (target > 1) {
+ if (maxDoubles > 0 && target % 2 == 0) {
+ maxDoubles--
+ target /= 2
+ } else {
+ if (maxDoubles == 0) {
+ count = count + target - 1
+ return count
+ } else {
+ target -= 1
+ }
+ }
+ count++
+ }
+ return count
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2140_solving_questions_with_brainpower/readme.md b/src/main/kotlin/g2101_2200/s2140_solving_questions_with_brainpower/readme.md
new file mode 100644
index 00000000..c17b6c8d
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2140_solving_questions_with_brainpower/readme.md
@@ -0,0 +1,76 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2140\. Solving Questions With Brainpower
+
+Medium
+
+You are given a **0-indexed** 2D integer array `questions` where questions[i] = [pointsi, brainpoweri].
+
+The array describes the questions of an exam, where you have to process the questions **in order** (i.e., starting from question `0`) and make a decision whether to **solve** or **skip** each question. Solving question `i` will **earn** you pointsi points but you will be **unable** to solve each of the next brainpoweri questions. If you skip question `i`, you get to make the decision on the next question.
+
+* For example, given `questions = \[\[3, 2], [4, 3], [4, 4], [2, 5]]`:
+ * If question `0` is solved, you will earn `3` points but you will be unable to solve questions `1` and `2`.
+ * If instead, question `0` is skipped and question `1` is solved, you will earn `4` points but you will be unable to solve questions `2` and `3`.
+
+Return _the **maximum** points you can earn for the exam_.
+
+**Example 1:**
+
+**Input:** questions = \[\[3,2],[4,3],[4,4],[2,5]]
+
+**Output:** 5
+
+**Explanation:** The maximum points can be earned by solving questions 0 and 3.
+
+- Solve question 0: Earn 3 points, will be unable to solve the next 2 questions
+
+- Unable to solve questions 1 and 2
+
+- Solve question 3: Earn 2 points
+
+Total points earned: 3 + 2 = 5. There is no other way to earn 5 or more points.
+
+**Example 2:**
+
+**Input:** questions = \[\[1,1],[2,2],[3,3],[4,4],[5,5]]
+
+**Output:** 7
+
+**Explanation:** The maximum points can be earned by solving questions 1 and 4.
+
+- Skip question 0
+
+- Solve question 1: Earn 2 points, will be unable to solve the next 2 questions
+
+- Unable to solve questions 2 and 3
+
+- Solve question 4: Earn 5 points
+
+Total points earned: 2 + 5 = 7. There is no other way to earn 7 or more points.
+
+**Constraints:**
+
+* 1 <= questions.length <= 105
+* `questions[i].length == 2`
+* 1 <= pointsi, brainpoweri <= 105
+
+## Solution
+
+```kotlin
+class Solution {
+ fun mostPoints(questions: Array): Long {
+ val n = questions.size
+ val memo = LongArray(n)
+ memo[n - 1] = questions[n - 1][0].toLong()
+ for (i in n - 2 downTo 0) {
+ if (i + questions[i][1] + 1 < n) {
+ memo[i] = Math.max(memo[i + 1], questions[i][0] + memo[i + questions[i][1] + 1])
+ } else {
+ memo[i] = Math.max(memo[i + 1], questions[i][0].toLong())
+ }
+ }
+ return memo[0]
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2141_maximum_running_time_of_n_computers/readme.md b/src/main/kotlin/g2101_2200/s2141_maximum_running_time_of_n_computers/readme.md
new file mode 100644
index 00000000..b6b54b1a
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2141_maximum_running_time_of_n_computers/readme.md
@@ -0,0 +1,87 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2141\. Maximum Running Time of N Computers
+
+Hard
+
+You have `n` computers. You are given the integer `n` and a **0-indexed** integer array `batteries` where the ith battery can **run** a computer for `batteries[i]` minutes. You are interested in running **all** `n` computers **simultaneously** using the given batteries.
+
+Initially, you can insert **at most one battery** into each computer. After that and at any integer time moment, you can remove a battery from a computer and insert another battery **any number of times**. The inserted battery can be a totally new battery or a battery from another computer. You may assume that the removing and inserting processes take no time.
+
+Note that the batteries cannot be recharged.
+
+Return _the **maximum** number of minutes you can run all the_ `n` _computers simultaneously._
+
+**Example 1:**
+
+
+
+**Input:** n = 2, batteries = [3,3,3]
+
+**Output:** 4
+
+**Explanation:**
+
+Initially, insert battery 0 into the first computer and battery 1 into the second computer.
+
+After two minutes, remove battery 1 from the second computer and insert battery 2 instead. Note that battery 1 can still run for one minute.
+
+At the end of the third minute, battery 0 is drained, and you need to remove it from the first computer and insert battery 1 instead.
+
+By the end of the fourth minute, battery 1 is also drained, and the first computer is no longer running.
+
+We can run the two computers simultaneously for at most 4 minutes, so we return 4.
+
+**Example 2:**
+
+
+
+**Input:** n = 2, batteries = [1,1,1,1]
+
+**Output:** 2
+
+**Explanation:**
+
+Initially, insert battery 0 into the first computer and battery 2 into the second computer.
+
+After one minute, battery 0 and battery 2 are drained so you need to remove them and insert battery 1 into the first computer and battery 3 into the second computer.
+
+After another minute, battery 1 and battery 3 are also drained so the first and second computers are no longer running.
+
+We can run the two computers simultaneously for at most 2 minutes, so we return 2.
+
+**Constraints:**
+
+* 1 <= n <= batteries.length <= 105
+* 1 <= batteries[i] <= 109
+
+## Solution
+
+```kotlin
+class Solution {
+ fun maxRunTime(n: Int, batteries: IntArray): Long {
+ var sumbatt: Long = 0
+ for (x in batteries) sumbatt += x.toLong()
+ var l: Long = 0
+ var r = sumbatt / n
+ var res = Long.MIN_VALUE
+ while (l <= r) {
+ val mid = (l + r) / 2
+ if (isPossible(mid, n, batteries)) {
+ res = mid
+ l = mid + 1
+ } else {
+ r = mid - 1
+ }
+ }
+ return res
+ }
+
+ private fun isPossible(mid: Long, n: Int, b: IntArray): Boolean {
+ var sum: Long = 0
+ for (x in b) sum += Math.min(x.toLong(), mid)
+ return n * mid <= sum
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2144_minimum_cost_of_buying_candies_with_discount/readme.md b/src/main/kotlin/g2101_2200/s2144_minimum_cost_of_buying_candies_with_discount/readme.md
new file mode 100644
index 00000000..41b241c2
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2144_minimum_cost_of_buying_candies_with_discount/readme.md
@@ -0,0 +1,80 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2144\. Minimum Cost of Buying Candies With Discount
+
+Easy
+
+A shop is selling candies at a discount. For **every two** candies sold, the shop gives a **third** candy for **free**.
+
+The customer can choose **any** candy to take away for free as long as the cost of the chosen candy is less than or equal to the **minimum** cost of the two candies bought.
+
+* For example, if there are `4` candies with costs `1`, `2`, `3`, and `4`, and the customer buys candies with costs `2` and `3`, they can take the candy with cost `1` for free, but not the candy with cost `4`.
+
+Given a **0-indexed** integer array `cost`, where `cost[i]` denotes the cost of the ith candy, return _the **minimum cost** of buying **all** the candies_.
+
+**Example 1:**
+
+**Input:** cost = [1,2,3]
+
+**Output:** 5
+
+**Explanation:** We buy the candies with costs 2 and 3, and take the candy with cost 1 for free.
+
+The total cost of buying all candies is 2 + 3 = 5. This is the **only** way we can buy the candies.
+
+Note that we cannot buy candies with costs 1 and 3, and then take the candy with cost 2 for free.
+
+The cost of the free candy has to be less than or equal to the minimum cost of the purchased candies.
+
+**Example 2:**
+
+**Input:** cost = [6,5,7,9,2,2]
+
+**Output:** 23
+
+**Explanation:** The way in which we can get the minimum cost is described below:
+
+- Buy candies with costs 9 and 7
+
+- Take the candy with cost 6 for free
+
+- We buy candies with costs 5 and 2
+
+- Take the last remaining candy with cost 2 for free
+
+Hence, the minimum cost to buy all candies is 9 + 7 + 5 + 2 = 23.
+
+**Example 3:**
+
+**Input:** cost = [5,5]
+
+**Output:** 10
+
+**Explanation:** Since there are only 2 candies, we buy both of them. There is not a third candy we can take for free.
+
+Hence, the minimum cost to buy all candies is 5 + 5 = 10.
+
+**Constraints:**
+
+* `1 <= cost.length <= 100`
+* `1 <= cost[i] <= 100`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minimumCost(cost: IntArray): Int {
+ cost.sort()
+ var size = 0
+ var sum = 0
+ for (i in cost.indices.reversed()) {
+ size++
+ if (size % 3 != 0) {
+ sum += cost[i]
+ }
+ }
+ return sum
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2145_count_the_hidden_sequences/readme.md b/src/main/kotlin/g2101_2200/s2145_count_the_hidden_sequences/readme.md
new file mode 100644
index 00000000..b35f0436
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2145_count_the_hidden_sequences/readme.md
@@ -0,0 +1,101 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2145\. Count the Hidden Sequences
+
+Medium
+
+You are given a **0-indexed** array of `n` integers `differences`, which describes the **differences** between each pair of **consecutive** integers of a **hidden** sequence of length `(n + 1)`. More formally, call the hidden sequence `hidden`, then we have that `differences[i] = hidden[i + 1] - hidden[i]`.
+
+You are further given two integers `lower` and `upper` that describe the **inclusive** range of values `[lower, upper]` that the hidden sequence can contain.
+
+* For example, given `differences = [1, -3, 4]`, `lower = 1`, `upper = 6`, the hidden sequence is a sequence of length `4` whose elements are in between `1` and `6` (**inclusive**).
+ * `[3, 4, 1, 5]` and `[4, 5, 2, 6]` are possible hidden sequences.
+ * `[5, 6, 3, 7]` is not possible since it contains an element greater than `6`.
+ * `[1, 2, 3, 4]` is not possible since the differences are not correct.
+
+Return _the number of **possible** hidden sequences there are._ If there are no possible sequences, return `0`.
+
+**Example 1:**
+
+**Input:** differences = [1,-3,4], lower = 1, upper = 6
+
+**Output:** 2
+
+**Explanation:** The possible hidden sequences are:
+
+- \[3, 4, 1, 5]
+
+- \[4, 5, 2, 6]
+
+Thus, we return 2.
+
+**Example 2:**
+
+**Input:** differences = [3,-4,5,1,-2], lower = -4, upper = 5
+
+**Output:** 4
+
+**Explanation:** The possible hidden sequences are:
+
+- \[-3, 0, -4, 1, 2, 0]
+
+- \[-2, 1, -3, 2, 3, 1]
+
+- \[-1, 2, -2, 3, 4, 2]
+
+- \[0, 3, -1, 4, 5, 3]
+
+Thus, we return 4.
+
+**Example 3:**
+
+**Input:** differences = [4,-7,2], lower = 3, upper = 6
+
+**Output:** 0
+
+**Explanation:** There are no possible hidden sequences. Thus, we return 0.
+
+**Constraints:**
+
+* `n == differences.length`
+* 1 <= n <= 105
+* -105 <= differences[i] <= 105
+* -105 <= lower <= upper <= 105
+
+## Solution
+
+```kotlin
+class Solution {
+ fun numberOfArrays(differences: IntArray, lower: Int, upper: Int): Int {
+ val n = differences.size
+ if (lower == upper) {
+ for (j in differences) {
+ if (j != 0) {
+ return 0
+ }
+ }
+ }
+ var max = (-1e9).toInt()
+ var min = 1e9.toInt()
+ val hidden = IntArray(n + 1)
+ hidden[0] = 0
+ for (i in 1..n) {
+ hidden[i] = hidden[i - 1] + differences[i - 1]
+ }
+ for (i in 0..n) {
+ if (hidden[i] > max) {
+ max = hidden[i]
+ }
+ if (hidden[i] < min) {
+ min = hidden[i]
+ }
+ }
+ val low = lower - min
+ val high = upper - max
+ return if (low > high) {
+ 0
+ } else high - low + 1
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2146_k_highest_ranked_items_within_a_price_range/readme.md b/src/main/kotlin/g2101_2200/s2146_k_highest_ranked_items_within_a_price_range/readme.md
new file mode 100644
index 00000000..d0248673
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2146_k_highest_ranked_items_within_a_price_range/readme.md
@@ -0,0 +1,166 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2146\. K Highest Ranked Items Within a Price Range
+
+Medium
+
+You are given a **0-indexed** 2D integer array `grid` of size `m x n` that represents a map of the items in a shop. The integers in the grid represent the following:
+
+* `0` represents a wall that you cannot pass through.
+* `1` represents an empty cell that you can freely move to and from.
+* All other positive integers represent the price of an item in that cell. You may also freely move to and from these item cells.
+
+It takes `1` step to travel between adjacent grid cells.
+
+You are also given integer arrays `pricing` and `start` where `pricing = [low, high]` and `start = [row, col]` indicates that you start at the position `(row, col)` and are interested only in items with a price in the range of `[low, high]` (**inclusive**). You are further given an integer `k`.
+
+You are interested in the **positions** of the `k` **highest-ranked** items whose prices are **within** the given price range. The rank is determined by the **first** of these criteria that is different:
+
+1. Distance, defined as the length of the shortest path from the `start` (**shorter** distance has a higher rank).
+2. Price (**lower** price has a higher rank, but it must be **in the price range**).
+3. The row number (**smaller** row number has a higher rank).
+4. The column number (**smaller** column number has a higher rank).
+
+Return _the_ `k` _highest-ranked items within the price range **sorted** by their rank (highest to lowest)_. If there are fewer than `k` reachable items within the price range, return _**all** of them_.
+
+**Example 1:**
+
+
+
+**Input:** grid = \[\[1,2,0,1],[1,3,0,1],[0,2,5,1]], pricing = [2,5], start = [0,0], k = 3
+
+**Output:** [[0,1],[1,1],[2,1]]
+
+**Explanation:** You start at (0,0).
+
+With a price range of [2,5], we can take items from (0,1), (1,1), (2,1) and (2,2).
+
+The ranks of these items are:
+
+- (0,1) with distance 1
+
+- (1,1) with distance 2
+
+- (2,1) with distance 3
+
+- (2,2) with distance 4
+
+Thus, the 3 highest ranked items in the price range are (0,1), (1,1), and (2,1).
+
+**Example 2:**
+
+
+
+**Input:** grid = \[\[1,2,0,1],[1,3,3,1],[0,2,5,1]], pricing = [2,3], start = [2,3], k = 2
+
+**Output:** [[2,1],[1,2]]
+
+**Explanation:** You start at (2,3).
+
+With a price range of [2,3], we can take items from (0,1), (1,1), (1,2) and (2,1).
+
+The ranks of these items are:
+
+- (2,1) with distance 2, price 2
+
+- (1,2) with distance 2, price 3
+
+- (1,1) with distance 3
+
+- (0,1) with distance 4
+
+Thus, the 2 highest ranked items in the price range are (2,1) and (1,2).
+
+**Example 3:**
+
+
+
+**Input:** grid = \[\[1,1,1],[0,0,1],[2,3,4]], pricing = [2,3], start = [0,0], k = 3
+
+**Output:** [[2,1],[2,0]]
+
+**Explanation:** You start at (0,0).
+
+With a price range of [2,3], we can take items from (2,0) and (2,1).
+
+The ranks of these items are:
+
+- (2,1) with distance 5
+
+- (2,0) with distance 6
+
+Thus, the 2 highest ranked items in the price range are (2,1) and (2,0).
+
+ Note that k = 3 but there are only 2 reachable items within the price range.
+
+**Constraints:**
+
+* `m == grid.length`
+* `n == grid[i].length`
+* 1 <= m, n <= 105
+* 1 <= m * n <= 105
+* 0 <= grid[i][j] <= 105
+* `pricing.length == 2`
+* 2 <= low <= high <= 105
+* `start.length == 2`
+* `0 <= row <= m - 1`
+* `0 <= col <= n - 1`
+* `grid[row][col] > 0`
+* `1 <= k <= m * n`
+
+## Solution
+
+```kotlin
+import java.util.ArrayDeque
+import java.util.Collections
+import java.util.Deque
+
+class Solution {
+ fun highestRankedKItems(grid: Array, pricing: IntArray, start: IntArray, k: Int): List> {
+ val m = grid.size
+ val n = grid[0].size
+ val row = start[0]
+ val col = start[1]
+ val low = pricing[0]
+ val high = pricing[1]
+ val items: MutableList = ArrayList()
+ if (grid[row][col] in low..high) items.add(intArrayOf(0, grid[row][col], row, col))
+ grid[row][col] = 0
+ val q: Deque = ArrayDeque()
+ q.offer(intArrayOf(row, col, 0))
+ val dirs = intArrayOf(-1, 0, 1, 0, -1)
+ while (q.isNotEmpty()) {
+ val p = q.poll()
+ val i = p[0]
+ val j = p[1]
+ val d = p[2]
+ for (l in 0..3) {
+ val x = i + dirs[l]
+ val y = j + dirs[l + 1]
+ if (x in 0 until m && y >= 0 && y < n && grid[x][y] > 0) {
+ if (grid[x][y] in low..high) {
+ items.add(intArrayOf(d + 1, grid[x][y], x, y))
+ }
+ grid[x][y] = 0
+ q.offer(intArrayOf(x, y, d + 1))
+ }
+ }
+ }
+ Collections.sort(items) { a: IntArray, b: IntArray ->
+ if (a[0] != b[0]) return@sort a[0] - b[0]
+ if (a[1] != b[1]) return@sort a[1] - b[1]
+ if (a[2] != b[2]) return@sort a[2] - b[2]
+ a[3] - b[3]
+ }
+ val ans: MutableList> = ArrayList()
+ var i = 0
+ while (i < items.size && i < k) {
+ val p = items[i]
+ ans.add(listOf(p[2], p[3]))
+ ++i
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2147_number_of_ways_to_divide_a_long_corridor/readme.md b/src/main/kotlin/g2101_2200/s2147_number_of_ways_to_divide_a_long_corridor/readme.md
new file mode 100644
index 00000000..ee88590d
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2147_number_of_ways_to_divide_a_long_corridor/readme.md
@@ -0,0 +1,99 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2147\. Number of Ways to Divide a Long Corridor
+
+Hard
+
+Along a long library corridor, there is a line of seats and decorative plants. You are given a **0-indexed** string `corridor` of length `n` consisting of letters `'S'` and `'P'` where each `'S'` represents a seat and each `'P'` represents a plant.
+
+One room divider has **already** been installed to the left of index `0`, and **another** to the right of index `n - 1`. Additional room dividers can be installed. For each position between indices `i - 1` and `i` (`1 <= i <= n - 1`), at most one divider can be installed.
+
+Divide the corridor into non-overlapping sections, where each section has **exactly two seats** with any number of plants. There may be multiple ways to perform the division. Two ways are **different** if there is a position with a room divider installed in the first way but not in the second way.
+
+Return _the number of ways to divide the corridor_. Since the answer may be very large, return it **modulo** 109 + 7. If there is no way, return `0`.
+
+**Example 1:**
+
+
+
+**Input:** corridor = "SSPPSPS"
+
+**Output:** 3
+
+**Explanation:** There are 3 different ways to divide the corridor.
+
+The black bars in the above image indicate the two room dividers already installed.
+
+Note that in each of the ways, **each** section has exactly **two** seats.
+
+**Example 2:**
+
+
+
+**Input:** corridor = "PPSPSP"
+
+**Output:** 1
+
+**Explanation:** There is only 1 way to divide the corridor, by not installing any additional dividers.
+
+Installing any would create some section that does not have exactly two seats.
+
+**Example 3:**
+
+
+
+**Input:** corridor = "S"
+
+**Output:** 0
+
+**Explanation:** There is no way to divide the corridor because there will always be a section that does not have exactly two seats.
+
+**Constraints:**
+
+* `n == corridor.length`
+* 1 <= n <= 105
+* `corridor[i]` is either `'S'` or `'P'`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun numberOfWays(corridor: String): Int {
+ var seat = 0
+ val mod = 1e9.toInt() + 7
+ for (i in 0 until corridor.length) {
+ if (corridor[i] == 'S') {
+ seat++
+ }
+ }
+ if (seat == 0 || seat % 2 != 0) {
+ return 0
+ }
+ seat /= 2
+ var curr: Long = 0
+ var ans: Long = 1
+ var i = 0
+ while (corridor[i] != 'S') {
+ i++
+ }
+ i++
+ while (seat > 1) {
+ while (corridor[i] != 'S') {
+ i++
+ }
+ i++
+ while (corridor[i] != 'S') {
+ i++
+ curr++
+ }
+ curr++
+ ans = ans * curr % mod
+ curr = 0
+ seat--
+ i++
+ }
+ return ans.toInt()
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2148_count_elements_with_strictly_smaller_and_greater_elements/readme.md b/src/main/kotlin/g2101_2200/s2148_count_elements_with_strictly_smaller_and_greater_elements/readme.md
new file mode 100644
index 00000000..eeb6a305
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2148_count_elements_with_strictly_smaller_and_greater_elements/readme.md
@@ -0,0 +1,63 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2148\. Count Elements With Strictly Smaller and Greater Elements
+
+Easy
+
+Given an integer array `nums`, return _the number of elements that have **both** a strictly smaller and a strictly greater element appear in_ `nums`.
+
+**Example 1:**
+
+**Input:** nums = [11,7,2,15]
+
+**Output:** 2
+
+**Explanation:** The element 7 has the element 2 strictly smaller than it and the element 11 strictly greater than it.
+
+Element 11 has element 7 strictly smaller than it and element 15 strictly greater than it.
+
+In total there are 2 elements having both a strictly smaller and a strictly greater element appear in `nums`.
+
+**Example 2:**
+
+**Input:** nums = [-3,3,3,90]
+
+**Output:** 2
+
+**Explanation:** The element 3 has the element -3 strictly smaller than it and the element 90 strictly greater than it.
+
+Since there are two elements with the value 3, in total there are 2 elements having both a strictly smaller and a strictly greater element appear in `nums`.
+
+**Constraints:**
+
+* `1 <= nums.length <= 100`
+* -105 <= nums[i] <= 105
+
+## Solution
+
+```kotlin
+class Solution {
+ fun countElements(nums: IntArray): Int {
+ var min = nums[0]
+ var max = nums[0]
+ var minocr = 1
+ var maxocr = 1
+ for (i in 1 until nums.size) {
+ if (nums[i] < min) {
+ min = nums[i]
+ minocr = 1
+ } else if (nums[i] == min) {
+ minocr++
+ }
+ if (nums[i] > max) {
+ max = nums[i]
+ maxocr = 1
+ } else if (nums[i] == max) {
+ maxocr++
+ }
+ }
+ return if (min == max) 0 else nums.size - minocr - maxocr
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2149_rearrange_array_elements_by_sign/readme.md b/src/main/kotlin/g2101_2200/s2149_rearrange_array_elements_by_sign/readme.md
new file mode 100644
index 00000000..5ae1569f
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2149_rearrange_array_elements_by_sign/readme.md
@@ -0,0 +1,76 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2149\. Rearrange Array Elements by Sign
+
+Medium
+
+You are given a **0-indexed** integer array `nums` of **even** length consisting of an **equal** number of positive and negative integers.
+
+You should **rearrange** the elements of `nums` such that the modified array follows the given conditions:
+
+1. Every **consecutive pair** of integers have **opposite signs**.
+2. For all integers with the same sign, the **order** in which they were present in `nums` is **preserved**.
+3. The rearranged array begins with a positive integer.
+
+Return _the modified array after rearranging the elements to satisfy the aforementioned conditions_.
+
+**Example 1:**
+
+**Input:** nums = [3,1,-2,-5,2,-4]
+
+**Output:** [3,-2,1,-5,2,-4]
+
+**Explanation:** The positive integers in nums are [3,1,2].
+
+The negative integers are [-2,-5,-4].
+
+The only possible way to rearrange them such that they satisfy all conditions is [3,-2,1,-5,2,-4].
+
+Other ways such as [1,-2,2,-5,3,-4], [3,1,2,-2,-5,-4], [-2,3,-5,1,-4,2] are incorrect because they do not satisfy one or more conditions.
+
+**Example 2:**
+
+**Input:** nums = [-1,1]
+
+**Output:** [1,-1]
+
+**Explanation:** 1 is the only positive integer and -1 the only negative integer in nums.
+
+So nums is rearranged to [1,-1].
+
+**Constraints:**
+
+* 2 <= nums.length <= 2 * 105
+* `nums.length` is **even**
+* 1 <= |nums[i]| <= 105
+* `nums` consists of **equal** number of positive and negative integers.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun rearrangeArray(nums: IntArray): IntArray {
+ val negatives = IntArray(nums.size / 2)
+ val positives = IntArray(nums.size / 2)
+ val result = IntArray(nums.size)
+ var pPtr = 0
+ var nPtr = 0
+ var rPtr = 0
+ for (num in nums) {
+ if (num > 0) {
+ positives[pPtr++] = num
+ } else {
+ negatives[nPtr++] = num
+ }
+ }
+ pPtr = 0
+ nPtr = 0
+ while (pPtr < positives.size && nPtr < negatives.size) {
+ result[rPtr++] = positives[pPtr++]
+ result[rPtr++] = negatives[nPtr++]
+ }
+ return result
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2150_find_all_lonely_numbers_in_the_array/readme.md b/src/main/kotlin/g2101_2200/s2150_find_all_lonely_numbers_in_the_array/readme.md
new file mode 100644
index 00000000..aa331e7d
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2150_find_all_lonely_numbers_in_the_array/readme.md
@@ -0,0 +1,71 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2150\. Find All Lonely Numbers in the Array
+
+Medium
+
+You are given an integer array `nums`. A number `x` is **lonely** when it appears only **once**, and no **adjacent** numbers (i.e. `x + 1` and `x - 1)` appear in the array.
+
+Return _**all** lonely numbers in_ `nums`. You may return the answer in **any order**.
+
+**Example 1:**
+
+**Input:** nums = [10,6,5,8]
+
+**Output:** [10,8]
+
+**Explanation:**
+
+- 10 is a lonely number since it appears exactly once and 9 and 11 does not appear in nums.
+
+- 8 is a lonely number since it appears exactly once and 7 and 9 does not appear in nums.
+
+- 5 is not a lonely number since 6 appears in nums and vice versa.
+
+Hence, the lonely numbers in nums are [10, 8].
+
+Note that [8, 10] may also be returned.
+
+**Example 2:**
+
+**Input:** nums = [1,3,5,3]
+
+**Output:** [1,5]
+
+**Explanation:**
+
+- 1 is a lonely number since it appears exactly once and 0 and 2 does not appear in nums.
+
+- 5 is a lonely number since it appears exactly once and 4 and 6 does not appear in nums.
+
+- 3 is not a lonely number since it appears twice.
+
+Hence, the lonely numbers in nums are [1, 5].
+
+Note that [5, 1] may also be returned.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* 0 <= nums[i] <= 106
+
+## Solution
+
+```kotlin
+class Solution {
+ fun findLonely(nums: IntArray): List {
+ val ans: MutableList = ArrayList()
+ val m = HashMap()
+ for (i in nums) {
+ m[i] = m.getOrDefault(i, 0) + 1
+ }
+ for (i in nums) {
+ if (m[i] == 1 && !m.containsKey(i - 1) && !m.containsKey(i + 1)) {
+ ans.add(i)
+ }
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2151_maximum_good_people_based_on_statements/readme.md b/src/main/kotlin/g2101_2200/s2151_maximum_good_people_based_on_statements/readme.md
new file mode 100644
index 00000000..2cf6cc35
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2151_maximum_good_people_based_on_statements/readme.md
@@ -0,0 +1,135 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2151\. Maximum Good People Based on Statements
+
+Hard
+
+There are two types of persons:
+
+* The **good person**: The person who always tells the truth.
+* The **bad person**: The person who might tell the truth and might lie.
+
+You are given a **0-indexed** 2D integer array `statements` of size `n x n` that represents the statements made by `n` people about each other. More specifically, `statements[i][j]` could be one of the following:
+
+* `0` which represents a statement made by person `i` that person `j` is a **bad** person.
+* `1` which represents a statement made by person `i` that person `j` is a **good** person.
+* `2` represents that **no statement** is made by person `i` about person `j`.
+
+Additionally, no person ever makes a statement about themselves. Formally, we have that `statements[i][i] = 2` for all `0 <= i < n`.
+
+Return _the **maximum** number of people who can be **good** based on the statements made by the_ `n` _people_.
+
+**Example 1:**
+
+
+
+**Input:** statements = \[\[2,1,2],[1,2,2],[2,0,2]]
+
+**Output:** 2
+
+**Explanation:**
+
+ Each person makes a single statement.
+ - Person 0 states that person 1 is good.
+ - Person 1 states that person 0 is good.
+ - Person 2 states that person 1 is bad.
+ Let's take person 2 as the key.
+ - Assuming that person 2 is a good person:
+ - Based on the statement made by person 2, person 1 is a bad person.
+ - Now we know for sure that person 1 is bad and person 2 is good.
+ - Based on the statement made by person 1, and since person 1 is bad, they could be:
+ - telling the truth. There will be a contradiction in this case and this assumption is invalid.
+ - lying. In this case, person 0 is also a bad person and lied in their statement.
+ - Following that person 2 is a good person, there will be only one good person in the group.
+ - Assuming that person 2 is a bad person:
+ - Based on the statement made by person 2, and since person 2 is bad, they could be:
+ - telling the truth. Following this scenario, person 0 and 1 are both bad as explained before.
+ - Following that person 2 is bad but told the truth, there will be no good persons in the group.
+ - lying. In this case person 1 is a good person.
+ - Since person 1 is a good person, person 0 is also a good person.
+ - Following that person 2 is bad and lied, there will be two good persons in the group.
+
+ We can see that at most 2 persons are good in the best case, so we return 2.
+ Note that there is more than one way to arrive at this conclusion.
+
+**Example 2:**
+
+
+
+**Input:** statements = \[\[2,0],[0,2]]
+
+**Output:** 1
+
+**Explanation:**
+
+ Each person makes a single statement.
+ - Person 0 states that person 1 is bad.
+ - Person 1 states that person 0 is bad.
+ Let's take person 0 as the key.
+ - Assuming that person 0 is a good person:
+ - Based on the statement made by person 0, person 1 is a bad person and was lying.
+ - Following that person 0 is a good person, there will be only one good person in the group.
+ - Assuming that person 0 is a bad person:
+ - Based on the statement made by person 0, and since person 0 is bad, they could be:
+ - telling the truth. Following this scenario, person 0 and 1 are both bad.
+ - Following that person 0 is bad but told the truth, there will be no good persons in the group.
+ - lying. In this case person 1 is a good person.
+ - Following that person 0 is bad and lied, there will be only one good person in the group.
+ We can see that at most, one person is good in the best case, so we return 1.
+ Note that there is more than one way to arrive at this conclusion.
+
+**Constraints:**
+
+* `n == statements.length == statements[i].length`
+* `2 <= n <= 15`
+* `statements[i][j]` is either `0`, `1`, or `2`.
+* `statements[i][i] == 2`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun maximumGood(statements: Array): Int {
+ val known = IntArray(statements.size)
+ known.fill(2)
+ return max(statements, known, 0)
+ }
+
+ private fun max(statements: Array, known: IntArray, position: Int): Int {
+ return if (position == statements.size) {
+ known.asSequence().filter { a: Int -> a == 1 }.count()
+ } else when (known[position]) {
+ 0 -> assumeBad(statements, known, position)
+ 1 -> assumeGood(statements, known, position)
+ else -> Math.max(
+ assumeBad(statements, known, position),
+ assumeGood(statements, known, position)
+ )
+ }
+ }
+
+ private fun assumeBad(statements: Array, known: IntArray, position: Int): Int {
+ val updatedKnown = known.clone()
+ updatedKnown[position] = 0
+ return max(statements, updatedKnown, position + 1)
+ }
+
+ private fun assumeGood(statements: Array, known: IntArray, position: Int): Int {
+ val updatedKnown = known.clone()
+ var conflictDetected = false
+ updatedKnown[position] = 1
+ for (i in statements[position].indices) {
+ val answer = statements[position][i]
+ if (answer != 2) {
+ if (known[i] != 2 && answer != known[i]) {
+ conflictDetected = true
+ break
+ }
+ updatedKnown[i] = answer
+ }
+ }
+ return if (conflictDetected) 0 else max(statements, updatedKnown, position + 1)
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2154_keep_multiplying_found_values_by_two/readme.md b/src/main/kotlin/g2101_2200/s2154_keep_multiplying_found_values_by_two/readme.md
new file mode 100644
index 00000000..b788936e
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2154_keep_multiplying_found_values_by_two/readme.md
@@ -0,0 +1,68 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2154\. Keep Multiplying Found Values by Two
+
+Easy
+
+You are given an array of integers `nums`. You are also given an integer `original` which is the first number that needs to be searched for in `nums`.
+
+You then do the following steps:
+
+1. If `original` is found in `nums`, **multiply** it by two (i.e., set `original = 2 * original`).
+2. Otherwise, **stop** the process.
+3. **Repeat** this process with the new number as long as you keep finding the number.
+
+Return _the **final** value of_ `original`.
+
+**Example 1:**
+
+**Input:** nums = [5,3,6,1,12], original = 3
+
+**Output:** 24
+
+**Explanation:**
+- 3 is found in nums. 3 is multiplied by 2 to obtain 6.
+
+- 6 is found in nums. 6 is multiplied by 2 to obtain 12.
+
+- 12 is found in nums. 12 is multiplied by 2 to obtain 24.
+
+- 24 is not found in nums.
+Thus, 24 is returned.
+
+**Example 2:**
+
+**Input:** nums = [2,7,9], original = 4
+
+**Output:** 4
+
+**Explanation:**
+- 4 is not found in nums.
+
+Thus, 4 is returned.
+
+**Constraints:**
+
+* `1 <= nums.length <= 1000`
+* `1 <= nums[i], original <= 1000`
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ fun findFinalValue(nums: IntArray, original: Int): Int {
+ var original = original
+ var i = 0
+ while (i < nums.size) {
+ if (nums[i] == original) {
+ original = original * 2
+ i = -1
+ }
+ i++
+ }
+ return original
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2155_all_divisions_with_the_highest_score_of_a_binary_array/readme.md b/src/main/kotlin/g2101_2200/s2155_all_divisions_with_the_highest_score_of_a_binary_array/readme.md
new file mode 100644
index 00000000..37d01bf9
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2155_all_divisions_with_the_highest_score_of_a_binary_array/readme.md
@@ -0,0 +1,112 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2155\. All Divisions With the Highest Score of a Binary Array
+
+Medium
+
+You are given a **0-indexed** binary array `nums` of length `n`. `nums` can be divided at index `i` (where `0 <= i <= n)` into two arrays (possibly empty) numsleft and numsright:
+
+* numsleft has all the elements of `nums` between index `0` and `i - 1` **(inclusive)**, while numsright has all the elements of nums between index `i` and `n - 1` **(inclusive)**.
+* If `i == 0`, numsleft is **empty**, while numsright has all the elements of `nums`.
+* If `i == n`, numsleft has all the elements of nums, while numsright is **empty**.
+
+The **division score** of an index `i` is the **sum** of the number of `0`'s in numsleft and the number of `1`'s in numsright.
+
+Return _**all distinct indices** that have the **highest** possible **division score**_. You may return the answer in **any order**.
+
+**Example 1:**
+
+**Input:** nums = [0,0,1,0]
+
+**Output:** [2,4]
+
+**Explanation:** Division at index
+- 0: numsleft is []. numsright is [0,0,**1**,0]. The score is 0 + 1 = 1.
+
+- 1: numsleft is [**0**]. numsright is [0,**1**,0]. The score is 1 + 1 = 2.
+
+- 2: numsleft is [**0**,**0**]. numsright is [**1**,0]. The score is 2 + 1 = 3.
+
+- 3: numsleft is [**0**,**0**,1]. numsright is [0]. The score is 2 + 0 = 2.
+
+- 4: numsleft is [**0**,**0**,1,**0**]. numsright is []. The score is 3 + 0 = 3.
+
+Indices 2 and 4 both have the highest possible division score 3.
+
+Note the answer [4,2] would also be accepted.
+
+**Example 2:**
+
+**Input:** nums = [0,0,0]
+
+**Output:** [3]
+
+**Explanation:** Division at index
+- 0: numsleft is []. numsright is [0,0,0]. The score is 0 + 0 = 0.
+
+- 1: numsleft is [**0**]. numsright is [0,0]. The score is 1 + 0 = 1.
+
+- 2: numsleft is [**0**,**0**]. numsright is [0]. The score is 2 + 0 = 2.
+
+- 3: numsleft is [**0**,**0**,**0**]. numsright is []. The score is 3 + 0 = 3.
+
+Only index 3 has the highest possible division score 3.
+
+**Example 3:**
+
+**Input:** nums = [1,1]
+
+**Output:** [0]
+
+**Explanation:** Division at index
+- 0: numsleft is []. numsright is [**1**,**1**]. The score is 0 + 2 = 2.
+
+- 1: numsleft is [1]. numsright is [**1**]. The score is 0 + 1 = 1.
+
+- 2: numsleft is [1,1]. numsright is []. The score is 0 + 0 = 0.
+
+Only index 0 has the highest possible division score 2.
+
+**Constraints:**
+
+* `n == nums.length`
+* 1 <= n <= 105
+* `nums[i]` is either `0` or `1`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun maxScoreIndices(nums: IntArray): List {
+ var curone = 0
+ var curzero = 0
+ var max = 0
+ for (i in nums) {
+ curone += i
+ }
+ val list: MutableList = ArrayList()
+ for (i in nums.indices) {
+ if (curzero + curone > max) {
+ list.clear()
+ list.add(i)
+ max = curzero + curone
+ } else if (curzero + curone == max) {
+ list.add(i)
+ }
+ if (nums[i] == 1) {
+ curone--
+ } else {
+ curzero++
+ }
+ }
+ if (curzero > max) {
+ list.clear()
+ list.add(nums.size)
+ } else if (curzero == max) {
+ list.add(nums.size)
+ }
+ return list
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2156_find_substring_with_given_hash_value/readme.md b/src/main/kotlin/g2101_2200/s2156_find_substring_with_given_hash_value/readme.md
new file mode 100644
index 00000000..abff4872
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2156_find_substring_with_given_hash_value/readme.md
@@ -0,0 +1,75 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2156\. Find Substring With Given Hash Value
+
+Hard
+
+The hash of a **0-indexed** string `s` of length `k`, given integers `p` and `m`, is computed using the following function:
+
+* hash(s, p, m) = (val(s[0]) * p0 + val(s[1]) * p1 + ... + val(s[k-1]) * pk-1) mod m.
+
+Where `val(s[i])` represents the index of `s[i]` in the alphabet from `val('a') = 1` to `val('z') = 26`.
+
+You are given a string `s` and the integers `power`, `modulo`, `k`, and `hashValue.` Return `sub`, _the **first** **substring** of_ `s` _of length_ `k` _such that_ `hash(sub, power, modulo) == hashValue`.
+
+The test cases will be generated such that an answer always **exists**.
+
+A **substring** is a contiguous non-empty sequence of characters within a string.
+
+**Example 1:**
+
+**Input:** s = "leetcode", power = 7, modulo = 20, k = 2, hashValue = 0
+
+**Output:** "ee"
+
+**Explanation:** The hash of "ee" can be computed to be hash("ee", 7, 20) = (5 \* 1 + 5 \* 7) mod 20 = 40 mod 20 = 0. "ee" is the first substring of length 2 with hashValue 0. Hence, we return "ee".
+
+**Example 2:**
+
+**Input:** s = "fbxzaad", power = 31, modulo = 100, k = 3, hashValue = 32
+
+**Output:** "fbx"
+
+**Explanation:** The hash of "fbx" can be computed to be hash("fbx", 31, 100) = (6 \* 1 + 2 \* 31 + 24 \* 312) mod 100 = 23132 mod 100 = 32.
+
+The hash of "bxz" can be computed to be hash("bxz", 31, 100) = (2 \* 1 + 24 \* 31 + 26 \* 312) mod 100 = 25732 mod 100 = 32. "fbx" is the first substring of length 3 with hashValue 32. Hence, we return "fbx".
+
+Note that "bxz" also has a hash of 32 but it appears later than "fbx".
+
+**Constraints:**
+
+* 1 <= k <= s.length <= 2 * 104
+* 1 <= power, modulo <= 109
+* `0 <= hashValue < modulo`
+* `s` consists of lowercase English letters only.
+* The test cases are generated such that an answer always **exists**.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun subStrHash(s: String, power: Int, modulo: Int, k: Int, hashValue: Int): String {
+ var mul1: Long = 1
+ var times = k - 1
+ while (times-- > 0) {
+ mul1 = mul1 * power % modulo
+ }
+ var index = -1
+ var hash: Long = 0
+ var end = s.length - 1
+ for (i in s.length - 1 downTo 0) {
+ val `val` = s[i].code - 96
+ hash = (hash * power % modulo + `val`) % modulo
+ if (end - i + 1 == k) {
+ if (hash == hashValue.toLong()) {
+ index = i
+ }
+ hash = (hash - (s[end].code - 96) * mul1 % modulo + modulo) % modulo
+ end--
+ }
+ }
+ return s.substring(index, index + k)
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2157_groups_of_strings/readme.md b/src/main/kotlin/g2101_2200/s2157_groups_of_strings/readme.md
new file mode 100644
index 00000000..f2e4ede8
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2157_groups_of_strings/readme.md
@@ -0,0 +1,122 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2157\. Groups of Strings
+
+Hard
+
+You are given a **0-indexed** array of strings `words`. Each string consists of **lowercase English letters** only. No letter occurs more than once in any string of `words`.
+
+Two strings `s1` and `s2` are said to be **connected** if the set of letters of `s2` can be obtained from the set of letters of `s1` by any **one** of the following operations:
+
+* Adding exactly one letter to the set of the letters of `s1`.
+* Deleting exactly one letter from the set of the letters of `s1`.
+* Replacing exactly one letter from the set of the letters of `s1` with any letter, **including** itself.
+
+The array `words` can be divided into one or more non-intersecting **groups**. A string belongs to a group if any **one** of the following is true:
+
+* It is connected to **at least one** other string of the group.
+* It is the **only** string present in the group.
+
+Note that the strings in `words` should be grouped in such a manner that a string belonging to a group cannot be connected to a string present in any other group. It can be proved that such an arrangement is always unique.
+
+Return _an array_ `ans` _of size_ `2` _where:_
+
+* `ans[0]` _is the **maximum number** of groups_ `words` _can be divided into, and_
+* `ans[1]` _is the **size of the largest** group_.
+
+**Example 1:**
+
+**Input:** words = ["a","b","ab","cde"]
+
+**Output:** [2,3]
+
+**Explanation:**
+
+- words[0] can be used to obtain words[1] (by replacing 'a' with 'b'), and words[2] (by adding 'b'). So words[0] is connected to words[1] and words[2].
+
+- words[1] can be used to obtain words[0] (by replacing 'b' with 'a'), and words[2] (by adding 'a'). So words[1] is connected to words[0] and words[2].
+
+- words[2] can be used to obtain words[0] (by deleting 'b'), and words[1] (by deleting 'a'). So words[2] is connected to words[0] and words[1].
+
+- words[3] is not connected to any string in words.
+
+Thus, words can be divided into 2 groups ["a","b","ab"] and ["cde"]. The size of the largest group is 3.
+
+**Example 2:**
+
+**Input:** words = ["a","ab","abc"]
+
+**Output:** [1,3]
+
+**Explanation:**
+
+- words[0] is connected to words[1].
+
+- words[1] is connected to words[0] and words[2].
+
+- words[2] is connected to words[1].
+
+Since all strings are connected to each other, they should be grouped together.
+
+Thus, the size of the largest group is 3.
+
+**Constraints:**
+
+* 1 <= words.length <= 2 * 104
+* `1 <= words[i].length <= 26`
+* `words[i]` consists of lowercase English letters only.
+* No letter occurs more than once in `words[i]`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun groupStrings(words: Array): IntArray {
+ val map = HashMap()
+ for (word in words) {
+ var bitmask = 0
+ for (ch in word.toCharArray()) {
+ bitmask = bitmask or (1 shl ch.code - 'a'.code)
+ }
+ map[bitmask] = map.getOrDefault(bitmask, 0) + 1
+ }
+ val keyset: MutableList = ArrayList()
+ for (key in map.keys) {
+ keyset.add(key)
+ }
+ var totalGroups = 0
+ var maxSize = 0
+ for (key in keyset) {
+ if (!map.containsKey(key)) {
+ continue
+ }
+ totalGroups++
+ val size = dfs(key, map)
+ maxSize = Math.max(size, maxSize)
+ }
+ return intArrayOf(totalGroups, maxSize)
+ }
+
+ private fun dfs(key: Int, map: HashMap): Int {
+ if (!map.containsKey(key)) {
+ return 0
+ }
+ var size = map[key]!!
+ map.remove(key)
+ for (i in 0..25) {
+ size += dfs(key xor (1 shl i), map)
+ }
+ for (i in 0..25) {
+ if (key and (1 shl i) > 0) {
+ for (j in 0..25) {
+ if (key and (1 shl j) == 0) {
+ size += dfs(key xor (1 shl i) xor (1 shl j), map)
+ }
+ }
+ }
+ }
+ return size
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2160_minimum_sum_of_four_digit_number_after_splitting_digits/readme.md b/src/main/kotlin/g2101_2200/s2160_minimum_sum_of_four_digit_number_after_splitting_digits/readme.md
new file mode 100644
index 00000000..51ab17c1
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2160_minimum_sum_of_four_digit_number_after_splitting_digits/readme.md
@@ -0,0 +1,57 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2160\. Minimum Sum of Four Digit Number After Splitting Digits
+
+Easy
+
+You are given a **positive** integer `num` consisting of exactly four digits. Split `num` into two new integers `new1` and `new2` by using the **digits** found in `num`. **Leading zeros** are allowed in `new1` and `new2`, and **all** the digits found in `num` must be used.
+
+* For example, given `num = 2932`, you have the following digits: two `2`'s, one `9` and one `3`. Some of the possible pairs `[new1, new2]` are `[22, 93]`, `[23, 92]`, `[223, 9]` and `[2, 329]`.
+
+Return _the **minimum** possible sum of_ `new1` _and_ `new2`.
+
+**Example 1:**
+
+**Input:** num = 2932
+
+**Output:** 52
+
+**Explanation:** Some possible pairs [new1, new2] are [29, 23], [223, 9], etc.
+
+The minimum sum can be obtained by the pair [29, 23]: 29 + 23 = 52.
+
+**Example 2:**
+
+**Input:** num = 4009
+
+**Output:** 13
+
+**Explanation:** Some possible pairs [new1, new2] are [0, 49], [490, 0], etc.
+
+The minimum sum can be obtained by the pair [4, 9]: 4 + 9 = 13.
+
+**Constraints:**
+
+* `1000 <= num <= 9999`
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ fun minimumSum(num: Int): Int {
+ var num = num
+ val digit = IntArray(4)
+ var cur = 0
+ while (num > 0) {
+ digit[cur++] = num % 10
+ num /= 10
+ }
+ digit.sort()
+ val num1 = digit[0] * 10 + digit[2]
+ val num2 = digit[1] * 10 + digit[3]
+ return num1 + num2
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2161_partition_array_according_to_given_pivot/readme.md b/src/main/kotlin/g2101_2200/s2161_partition_array_according_to_given_pivot/readme.md
new file mode 100644
index 00000000..7ffdc261
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2161_partition_array_according_to_given_pivot/readme.md
@@ -0,0 +1,81 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2161\. Partition Array According to Given Pivot
+
+Medium
+
+You are given a **0-indexed** integer array `nums` and an integer `pivot`. Rearrange `nums` such that the following conditions are satisfied:
+
+* Every element less than `pivot` appears **before** every element greater than `pivot`.
+* Every element equal to `pivot` appears **in between** the elements less than and greater than `pivot`.
+* The **relative order** of the elements less than `pivot` and the elements greater than `pivot` is maintained.
+ * More formally, consider every pi, pj where pi is the new position of the ith element and pj is the new position of the jth element. For elements less than `pivot`, if `i < j` and `nums[i] < pivot` and `nums[j] < pivot`, then pi < pj. Similarly for elements greater than `pivot`, if `i < j` and `nums[i] > pivot` and `nums[j] > pivot`, then pi < pj.
+
+Return `nums` _after the rearrangement._
+
+**Example 1:**
+
+**Input:** nums = [9,12,5,10,14,3,10], pivot = 10
+
+**Output:** [9,5,3,10,10,12,14]
+
+**Explanation:** The elements 9, 5, and 3 are less than the pivot so they are on the left side of the array.
+
+The elements 12 and 14 are greater than the pivot so they are on the right side of the array.
+
+The relative ordering of the elements less than and greater than pivot is also maintained.
+
+[9, 5, 3] and [12, 14] are the respective orderings.
+
+**Example 2:**
+
+**Input:** nums = [-3,4,3,2], pivot = 2
+
+**Output:** [-3,2,4,3]
+
+**Explanation:** The element -3 is less than the pivot so it is on the left side of the array.
+
+elements 4 and 3 are greater than the pivot so they are on the right side of the array.
+
+The relative ordering of the elements less than and greater than pivot is also maintained.
+
+[-3] and [4, 3] are the respective orderings.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* -106 <= nums[i] <= 106
+* `pivot` equals to an element of `nums`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun pivotArray(nums: IntArray, pivot: Int): IntArray {
+ val ans = IntArray(nums.size)
+ var point = 0
+ var equal = 0
+ for (i in nums) {
+ if (i < pivot) {
+ ans[point] = i
+ ++point
+ } else if (i == pivot) {
+ ++equal
+ }
+ }
+ while (equal > 0) {
+ ans[point] = pivot
+ ++point
+ --equal
+ }
+ for (i in nums) {
+ if (i > pivot) {
+ ans[point] = i
+ ++point
+ }
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2162_minimum_cost_to_set_cooking_time/readme.md b/src/main/kotlin/g2101_2200/s2162_minimum_cost_to_set_cooking_time/readme.md
new file mode 100644
index 00000000..4c97afcb
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2162_minimum_cost_to_set_cooking_time/readme.md
@@ -0,0 +1,109 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2162\. Minimum Cost to Set Cooking Time
+
+Medium
+
+A generic microwave supports cooking times for:
+
+* at least `1` second.
+* at most `99` minutes and `99` seconds.
+
+To set the cooking time, you push **at most four digits**. The microwave normalizes what you push as four digits by **prepending zeroes**. It interprets the **first** two digits as the minutes and the **last** two digits as the seconds. It then **adds** them up as the cooking time. For example,
+
+* You push `9` `5` `4` (three digits). It is normalized as `0954` and interpreted as `9` minutes and `54` seconds.
+* You push `0` `0` `0` `8` (four digits). It is interpreted as `0` minutes and `8` seconds.
+* You push `8` `0` `9` `0`. It is interpreted as `80` minutes and `90` seconds.
+* You push `8` `1` `3` `0`. It is interpreted as `81` minutes and `30` seconds.
+
+You are given integers `startAt`, `moveCost`, `pushCost`, and `targetSeconds`. **Initially**, your finger is on the digit `startAt`. Moving the finger above **any specific digit** costs `moveCost` units of fatigue. Pushing the digit below the finger **once** costs `pushCost` units of fatigue.
+
+There can be multiple ways to set the microwave to cook for `targetSeconds` seconds but you are interested in the way with the minimum cost.
+
+Return _the **minimum cost** to set_ `targetSeconds` _seconds of cooking time_.
+
+Remember that one minute consists of `60` seconds.
+
+**Example 1:**
+
+
+
+**Input:** startAt = 1, moveCost = 2, pushCost = 1, targetSeconds = 600
+
+**Output:** 6
+
+**Explanation:** The following are the possible ways to set the cooking time.
+
+- 1 0 0 0, interpreted as 10 minutes and 0 seconds.
+
+The finger is already on digit 1, pushes 1 (with cost 1), moves to 0 (with cost 2), pushes 0 (with cost 1), pushes 0 (with cost 1), and pushes 0 (with cost 1).
+
+The cost is: 1 + 2 + 1 + 1 + 1 = 6. This is the minimum cost.
+
+- 0 9 6 0, interpreted as 9 minutes and 60 seconds. That is also 600 seconds.
+
+The finger moves to 0 (with cost 2), pushes 0 (with cost 1), moves to 9 (with cost 2), pushes 9 (with cost 1), moves to 6 (with cost 2), pushes 6 (with cost 1), moves to 0 (with cost 2), and pushes 0 (with cost 1).
+
+The cost is: 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 = 12.
+
+- 9 6 0, normalized as 0960 and interpreted as 9 minutes and 60 seconds.
+
+The finger moves to 9 (with cost 2), pushes 9 (with cost 1), moves to 6 (with cost 2), pushes 6 (with cost 1), moves to 0 (with cost 2), and pushes 0 (with cost 1).
+
+The cost is: 2 + 1 + 2 + 1 + 2 + 1 = 9.
+
+**Example 2:**
+
+
+
+**Input:** startAt = 0, moveCost = 1, pushCost = 2, targetSeconds = 76
+
+**Output:** 6
+
+**Explanation:** The optimal way is to push two digits: 7 6, interpreted as 76 seconds.
+
+The finger moves to 7 (with cost 1), pushes 7 (with cost 2), moves to 6 (with cost 1), and pushes 6 (with cost 2).
+
+The total cost is: 1 + 2 + 1 + 2 = 6
+
+Note other possible ways are 0076, 076, 0116, and 116, but none of them produces the minimum cost.
+
+**Constraints:**
+
+* `0 <= startAt <= 9`
+* 1 <= moveCost, pushCost <= 105
+* `1 <= targetSeconds <= 6039`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minCostSetTime(startAt: Int, moveCost: Int, pushCost: Int, targetSeconds: Int): Int {
+ val mins = targetSeconds / 60
+ val secs = targetSeconds % 60
+ return Math.min(
+ cost(mins, secs, startAt, moveCost, pushCost),
+ cost(mins - 1, secs + 60, startAt, moveCost, pushCost)
+ )
+ }
+
+ private fun cost(mins: Int, secs: Int, startAt: Int, moveCost: Int, pushCost: Int): Int {
+ if (mins > 99 || secs > 99 || mins < 0 || secs < 0) {
+ return Int.MAX_VALUE
+ }
+ val s = Integer.toString(mins * 100 + secs)
+ var curr = (startAt + '0'.code).toChar()
+ var res = 0
+ for (i in 0 until s.length) {
+ if (s[i] == curr) {
+ res += pushCost
+ } else {
+ res += pushCost + moveCost
+ curr = s[i]
+ }
+ }
+ return res
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2163_minimum_difference_in_sums_after_removal_of_elements/readme.md b/src/main/kotlin/g2101_2200/s2163_minimum_difference_in_sums_after_removal_of_elements/readme.md
new file mode 100644
index 00000000..3e1b9b05
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2163_minimum_difference_in_sums_after_removal_of_elements/readme.md
@@ -0,0 +1,104 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2163\. Minimum Difference in Sums After Removal of Elements
+
+Hard
+
+You are given a **0-indexed** integer array `nums` consisting of `3 * n` elements.
+
+You are allowed to remove any **subsequence** of elements of size **exactly** `n` from `nums`. The remaining `2 * n` elements will be divided into two **equal** parts:
+
+* The first `n` elements belonging to the first part and their sum is sumfirst.
+* The next `n` elements belonging to the second part and their sum is sumsecond.
+
+The **difference in sums** of the two parts is denoted as sumfirst - sumsecond.
+
+* For example, if sumfirst = 3 and sumsecond = 2, their difference is `1`.
+* Similarly, if sumfirst = 2 and sumsecond = 3, their difference is `-1`.
+
+Return _the **minimum difference** possible between the sums of the two parts after the removal of_ `n` _elements_.
+
+**Example 1:**
+
+**Input:** nums = [3,1,2]
+
+**Output:** -1
+
+**Explanation:** Here, nums has 3 elements, so n = 1.
+
+Thus we have to remove 1 element from nums and divide the array into two equal parts.
+
+- If we remove nums[0] = 3, the array will be [1,2]. The difference in sums of the two parts will be 1 - 2 = -1.
+
+- If we remove nums[1] = 1, the array will be [3,2]. The difference in sums of the two parts will be 3 - 2 = 1.
+
+- If we remove nums[2] = 2, the array will be [3,1]. The difference in sums of the two parts will be 3 - 1 = 2.
+
+The minimum difference between sums of the two parts is min(-1,1,2) = -1.
+
+**Example 2:**
+
+**Input:** nums = [7,9,5,8,1,3]
+
+**Output:** 1
+
+**Explanation:** Here n = 2. So we must remove 2 elements and divide the remaining array into two parts containing two elements each.
+
+If we remove nums[2] = 5 and nums[3] = 8, the resultant array will be [7,9,1,3]. The difference in sums will be (7+9) - (1+3) = 12.
+
+To obtain the minimum difference, we should remove nums[1] = 9 and nums[4] = 1. The resultant array becomes [7,5,8,3]. The difference in sums of the two parts is (7+5) - (8+3) = 1.
+
+It can be shown that it is not possible to obtain a difference smaller than 1.
+
+**Constraints:**
+
+* `nums.length == 3 * n`
+* 1 <= n <= 105
+* 1 <= nums[i] <= 105
+
+## Solution
+
+```kotlin
+import java.util.PriorityQueue
+
+class Solution {
+ fun minimumDifference(nums: IntArray): Long {
+ val n = nums.size / 3
+ val minHeap = PriorityQueue()
+ val maxHeap = PriorityQueue { a: Int, b: Int -> b - a }
+ val leftMemo = LongArray(nums.size)
+ val rightMemo = LongArray(nums.size)
+ var current = 0L
+ for (i in 0..2 * n - 1) {
+ current += nums[i].toLong()
+ maxHeap.add(nums[i])
+ if (maxHeap.size > n) {
+ val removed = maxHeap.poll()
+ current -= removed.toLong()
+ leftMemo[i] = current
+ }
+ if (maxHeap.size == n) {
+ leftMemo[i] = current
+ }
+ }
+ current = 0
+ for (i in nums.size - 1 downTo n) {
+ current += nums[i].toLong()
+ minHeap.add(nums[i])
+ if (minHeap.size > n) {
+ val removed = minHeap.poll()
+ current -= removed.toLong()
+ }
+ if (minHeap.size == n) {
+ rightMemo[i] = current
+ }
+ }
+ var min = Long.MAX_VALUE
+ for (i in n - 1..2 * n - 1) {
+ min = Math.min(min, leftMemo[i] - rightMemo[i + 1])
+ }
+ return min
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2164_sort_even_and_odd_indices_independently/readme.md b/src/main/kotlin/g2101_2200/s2164_sort_even_and_odd_indices_independently/readme.md
new file mode 100644
index 00000000..07df313c
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2164_sort_even_and_odd_indices_independently/readme.md
@@ -0,0 +1,82 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2164\. Sort Even and Odd Indices Independently
+
+Easy
+
+You are given a **0-indexed** integer array `nums`. Rearrange the values of `nums` according to the following rules:
+
+1. Sort the values at **odd indices** of `nums` in **non-increasing** order.
+ * For example, if nums = [4,**1**,2,**3**] before this step, it becomes [4,**3**,2,**1**] after. The values at odd indices `1` and `3` are sorted in non-increasing order.
+2. Sort the values at **even indices** of `nums` in **non-decreasing** order.
+ * For example, if nums = [**4**,1,**2**,3] before this step, it becomes [**2**,1,**4**,3] after. The values at even indices `0` and `2` are sorted in non-decreasing order.
+
+Return _the array formed after rearranging the values of_ `nums`.
+
+**Example 1:**
+
+**Input:** nums = [4,1,2,3]
+
+**Output:** [2,3,4,1]
+
+**Explanation:**
+
+First, we sort the values present at odd indices (1 and 3) in non-increasing order.
+
+So, nums changes from [4,**1**,2,**3**] to [4,**3**,2,**1**].
+
+Next, we sort the values present at even indices (0 and 2) in non-decreasing order. So, nums changes from [**4**,1,**2**,3] to [**2**,3,**4**,1].
+
+Thus, the array formed after rearranging the values is [2,3,4,1].
+
+**Example 2:**
+
+**Input:** nums = [2,1]
+
+**Output:** [2,1]
+
+**Explanation:** Since there is exactly one odd index and one even index, no rearrangement of values takes place.
+
+The resultant array formed is [2,1], which is the same as the initial array.
+
+**Constraints:**
+
+* `1 <= nums.length <= 100`
+* `1 <= nums[i] <= 100`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun sortEvenOdd(nums: IntArray): IntArray {
+ val odd = IntArray(nums.size / 2)
+ val even = IntArray((nums.size + 1) / 2)
+ var o = 0
+ var e = 0
+ for (i in nums.indices) {
+ if (i % 2 == 0) {
+ even[e] = nums[i]
+ ++e
+ } else {
+ odd[o] = nums[i]
+ ++o
+ }
+ }
+ odd.sort()
+ even.sort()
+ e = 0
+ o = odd.size - 1
+ for (i in nums.indices) {
+ if (i % 2 == 0) {
+ nums[i] = even[e]
+ ++e
+ } else {
+ nums[i] = odd[o]
+ --o
+ }
+ }
+ return nums
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2165_smallest_value_of_the_rearranged_number/readme.md b/src/main/kotlin/g2101_2200/s2165_smallest_value_of_the_rearranged_number/readme.md
new file mode 100644
index 00000000..52756138
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2165_smallest_value_of_the_rearranged_number/readme.md
@@ -0,0 +1,79 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2165\. Smallest Value of the Rearranged Number
+
+Medium
+
+You are given an integer `num.` **Rearrange** the digits of `num` such that its value is **minimized** and it does not contain **any** leading zeros.
+
+Return _the rearranged number with minimal value_.
+
+Note that the sign of the number does not change after rearranging the digits.
+
+**Example 1:**
+
+**Input:** num = 310
+
+**Output:** 103
+
+**Explanation:** The possible arrangements for the digits of 310 are 013, 031, 103, 130, 301, 310.
+
+The arrangement with the smallest value that does not contain any leading zeros is 103.
+
+**Example 2:**
+
+**Input:** num = -7605
+
+**Output:** -7650
+
+**Explanation:** Some possible arrangements for the digits of -7605 are -7650, -6705, -5076, -0567.
+
+The arrangement with the smallest value that does not contain any leading zeros is -7650.
+
+**Constraints:**
+
+* -1015 <= num <= 1015
+
+## Solution
+
+```kotlin
+class Solution {
+ fun smallestNumber(num: Long): Long {
+ val count = IntArray(10)
+ var tempNum: Long
+ tempNum = if (num > 0) {
+ num
+ } else {
+ num * -1
+ }
+ var min = 10
+ while (tempNum > 0) {
+ val rem = (tempNum % 10).toInt()
+ if (rem != 0) {
+ min = Math.min(min, rem)
+ }
+ count[rem]++
+ tempNum = tempNum / 10
+ }
+ var output: Long = 0
+ if (num > 0) {
+ output = output * 10 + min
+ count[min]--
+ for (i in 0..9) {
+ for (j in 0 until count[i]) {
+ output = output * 10 + i
+ }
+ }
+ } else {
+ for (i in 9 downTo 0) {
+ for (j in 0 until count[i]) {
+ output = output * 10 + i
+ }
+ }
+ output = output * -1
+ }
+ return output
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2166_design_bitset/readme.md b/src/main/kotlin/g2101_2200/s2166_design_bitset/readme.md
new file mode 100644
index 00000000..366cdabc
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2166_design_bitset/readme.md
@@ -0,0 +1,121 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2166\. Design Bitset
+
+Medium
+
+A **Bitset** is a data structure that compactly stores bits.
+
+Implement the `Bitset` class:
+
+* `Bitset(int size)` Initializes the Bitset with `size` bits, all of which are `0`.
+* `void fix(int idx)` Updates the value of the bit at the index `idx` to `1`. If the value was already `1`, no change occurs.
+* `void unfix(int idx)` Updates the value of the bit at the index `idx` to `0`. If the value was already `0`, no change occurs.
+* `void flip()` Flips the values of each bit in the Bitset. In other words, all bits with value `0` will now have value `1` and vice versa.
+* `boolean all()` Checks if the value of **each** bit in the Bitset is `1`. Returns `true` if it satisfies the condition, `false` otherwise.
+* `boolean one()` Checks if there is **at least one** bit in the Bitset with value `1`. Returns `true` if it satisfies the condition, `false` otherwise.
+* `int count()` Returns the **total number** of bits in the Bitset which have value `1`.
+* `String toString()` Returns the current composition of the Bitset. Note that in the resultant string, the character at the ith index should coincide with the value at the ith bit of the Bitset.
+
+**Example 1:**
+
+**Input**
+
+["Bitset", "fix", "fix", "flip", "all", "unfix", "flip", "one", "unfix", "count", "toString"]
+
+[[5], [3], [1], [], [], [0], [], [], [0], [], []]
+
+**Output:** [null, null, null, null, false, null, null, true, null, 2, "01010"]
+
+**Explanation:**
+
+ Bitset bs = new Bitset(5); // bitset = "00000".
+ bs.fix(3); // the value at idx = 3 is updated to 1, so bitset = "00010".
+ bs.fix(1); // the value at idx = 1 is updated to 1, so bitset = "01010".
+ bs.flip(); // the value of each bit is flipped, so bitset = "10101".
+ bs.all(); // return False, as not all values of the bitset are 1.
+ bs.unfix(0); // the value at idx = 0 is updated to 0, so bitset = "00101".
+ bs.flip(); // the value of each bit is flipped, so bitset = "11010".
+ bs.one(); // return True, as there is at least 1 index with value 1.
+ bs.unfix(0); // the value at idx = 0 is updated to 0, so bitset = "01010".
+ bs.count(); // return 2, as there are 2 bits with value 1.
+ bs.toString(); // return "01010", which is the composition of bitset.
+
+**Constraints:**
+
+* 1 <= size <= 105
+* `0 <= idx <= size - 1`
+* At most 105 calls will be made **in total** to `fix`, `unfix`, `flip`, `all`, `one`, `count`, and `toString`.
+* At least one call will be made to `all`, `one`, `count`, or `toString`.
+* At most `5` calls will be made to `toString`.
+
+## Solution
+
+```kotlin
+class Bitset(private val sz: Int) {
+ private var bits: BooleanArray
+ private var flipped: BooleanArray
+ private var cnt = 0
+
+ init {
+ bits = BooleanArray(sz)
+ flipped = BooleanArray(sz)
+ flipped.fill(true)
+ }
+
+ fun fix(idx: Int) {
+ if (!bits[idx]) {
+ bits[idx] = bits[idx] xor true
+ flipped[idx] = flipped[idx] xor true
+ cnt += 1
+ }
+ }
+
+ fun unfix(idx: Int) {
+ if (bits[idx]) {
+ bits[idx] = bits[idx] xor true
+ flipped[idx] = flipped[idx] xor true
+ cnt -= 1
+ }
+ }
+
+ fun flip() {
+ val tmp = bits
+ bits = flipped
+ flipped = tmp
+ cnt = sz - cnt
+ }
+
+ fun all(): Boolean {
+ return cnt == sz
+ }
+
+ fun one(): Boolean {
+ return cnt > 0
+ }
+
+ fun count(): Int {
+ return cnt
+ }
+
+ override fun toString(): String {
+ val sb = StringBuilder()
+ for (b in bits) {
+ sb.append(if (b) '1' else '0')
+ }
+ return sb.toString()
+ }
+}
+/*
+ * Your Bitset object will be instantiated and called as such:
+ * var obj = Bitset(size)
+ * obj.fix(idx)
+ * obj.unfix(idx)
+ * obj.flip()
+ * var param_4 = obj.all()
+ * var param_5 = obj.one()
+ * var param_6 = obj.count()
+ * var param_7 = obj.toString()
+ */
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2167_minimum_time_to_remove_all_cars_containing_illegal_goods/readme.md b/src/main/kotlin/g2101_2200/s2167_minimum_time_to_remove_all_cars_containing_illegal_goods/readme.md
new file mode 100644
index 00000000..595765e8
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2167_minimum_time_to_remove_all_cars_containing_illegal_goods/readme.md
@@ -0,0 +1,95 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2167\. Minimum Time to Remove All Cars Containing Illegal Goods
+
+Hard
+
+You are given a **0-indexed** binary string `s` which represents a sequence of train cars. `s[i] = '0'` denotes that the ith car does **not** contain illegal goods and `s[i] = '1'` denotes that the ith car does contain illegal goods.
+
+As the train conductor, you would like to get rid of all the cars containing illegal goods. You can do any of the following three operations **any** number of times:
+
+1. Remove a train car from the **left** end (i.e., remove `s[0]`) which takes 1 unit of time.
+2. Remove a train car from the **right** end (i.e., remove `s[s.length - 1]`) which takes 1 unit of time.
+3. Remove a train car from **anywhere** in the sequence which takes 2 units of time.
+
+Return _the **minimum** time to remove all the cars containing illegal goods_.
+
+Note that an empty sequence of cars is considered to have no cars containing illegal goods.
+
+**Example 1:**
+
+**Input:** s = "**11**00**1**0**1**"
+
+**Output:** 5
+
+**Explanation:**
+
+One way to remove all the cars containing illegal goods from the sequence is to
+
+- remove a car from the left end 2 times. Time taken is 2 \* 1 = 2.
+
+- remove a car from the right end. Time taken is 1.
+
+- remove the car containing illegal goods found in the middle. Time taken is 2. This obtains a total time of 2 + 1 + 2 = 5. An alternative way is to
+
+- remove a car from the left end 2 times. Time taken is 2 \* 1 = 2.
+
+- remove a car from the right end 3 times. Time taken is 3 \* 1 = 3. This also obtains a total time of 2 + 3 = 5.
+
+5 is the minimum time taken to remove all the cars containing illegal goods. There are no other ways to remove them with less time.
+
+**Example 2:**
+
+**Input:** s = "00**1**0"
+
+**Output:** 2
+
+**Explanation:** One way to remove all the cars containing illegal goods from the sequence is to
+
+- remove a car from the left end 3 times. Time taken is 3 \* 1 = 3.
+
+This obtains a total time of 3.
+
+Another way to remove all the cars containing illegal goods from the sequence is to
+
+- remove the car containing illegal goods found in the middle. Time taken is 2. This obtains a total time of 2.
+
+Another way to remove all the cars containing illegal goods from the sequence is to
+
+- remove a car from the right end 2 times. Time taken is 2 \* 1 = 2.
+
+This obtains a total time of 2.
+
+2 is the minimum time taken to remove all the cars containing illegal goods.
+
+There are no other ways to remove them with less time.
+
+**Constraints:**
+
+* 1 <= s.length <= 2 * 105
+* `s[i]` is either `'0'` or `'1'`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minimumTime(s: String): Int {
+ val n = s.length
+ val sum = IntArray(n + 1)
+ for (i in 0 until n) {
+ sum[i + 1] = sum[i] + (s[i].code - '0'.code)
+ }
+ if (sum[n] == 0) {
+ return 0
+ }
+ var res = s.length
+ var min = Int.MAX_VALUE
+ for (end in 0 until n) {
+ min = Math.min(min, end - 2 * sum[end] + n - 1)
+ res = Math.min(res, min + 2 * sum[end + 1] - end)
+ }
+ return res
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2169_count_operations_to_obtain_zero/readme.md b/src/main/kotlin/g2101_2200/s2169_count_operations_to_obtain_zero/readme.md
new file mode 100644
index 00000000..813decba
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2169_count_operations_to_obtain_zero/readme.md
@@ -0,0 +1,73 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2169\. Count Operations to Obtain Zero
+
+Easy
+
+You are given two **non-negative** integers `num1` and `num2`.
+
+In one **operation**, if `num1 >= num2`, you must subtract `num2` from `num1`, otherwise subtract `num1` from `num2`.
+
+* For example, if `num1 = 5` and `num2 = 4`, subtract `num2` from `num1`, thus obtaining `num1 = 1` and `num2 = 4`. However, if `num1 = 4` and `num2 = 5`, after one operation, `num1 = 4` and `num2 = 1`.
+
+Return _the **number of operations** required to make either_ `num1 = 0` _or_ `num2 = 0`.
+
+**Example 1:**
+
+**Input:** num1 = 2, num2 = 3
+
+**Output:** 3
+
+**Explanation:**
+
+- Operation 1: num1 = 2, num2 = 3. Since num1 < num2, we subtract num1 from num2 and get num1 = 2, num2 = 3 - 2 = 1.
+
+- Operation 2: num1 = 2, num2 = 1. Since num1 > num2, we subtract num2 from num1.
+
+- Operation 3: num1 = 1, num2 = 1. Since num1 == num2, we subtract num2 from num1.
+
+Now num1 = 0 and num2 = 1. Since num1 == 0, we do not need to perform any further operations.
+
+So the total number of operations required is 3.
+
+**Example 2:**
+
+**Input:** num1 = 10, num2 = 10
+
+**Output:** 1
+
+**Explanation:**
+
+- Operation 1: num1 = 10, num2 = 10. Since num1 == num2, we subtract num2 from num1 and get num1 = 10 - 10 = 0.
+
+Now num1 = 0 and num2 = 10. Since num1 == 0, we are done.
+
+So the total number of operations required is 1.
+
+**Constraints:**
+
+* 0 <= num1, num2 <= 105
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ fun countOperations(num1: Int, num2: Int): Int {
+ var num1 = num1
+ var num2 = num2
+ var ans = 0
+ while (num1 * num2 != 0) {
+ if (num1 >= num2) {
+ ans += num1 / num2
+ num1 = num1 % num2
+ } else {
+ ans += num2 / num1
+ num2 = num2 % num1
+ }
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2170_minimum_operations_to_make_the_array_alternating/readme.md b/src/main/kotlin/g2101_2200/s2170_minimum_operations_to_make_the_array_alternating/readme.md
new file mode 100644
index 00000000..63625837
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2170_minimum_operations_to_make_the_array_alternating/readme.md
@@ -0,0 +1,107 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2170\. Minimum Operations to Make the Array Alternating
+
+Medium
+
+You are given a **0-indexed** array `nums` consisting of `n` positive integers.
+
+The array `nums` is called **alternating** if:
+
+* `nums[i - 2] == nums[i]`, where `2 <= i <= n - 1`.
+* `nums[i - 1] != nums[i]`, where `1 <= i <= n - 1`.
+
+In one **operation**, you can choose an index `i` and **change** `nums[i]` into **any** positive integer.
+
+Return _the **minimum number of operations** required to make the array alternating_.
+
+**Example 1:**
+
+**Input:** nums = [3,1,3,2,4,3]
+
+**Output:** 3
+
+**Explanation:**
+
+One way to make the array alternating is by converting it to [3,1,3,**1**,**3**,**1**].
+
+The number of operations required in this case is 3.
+
+It can be proven that it is not possible to make the array alternating in less than 3 operations.
+
+**Example 2:**
+
+**Input:** nums = [1,2,2,2,2]
+
+**Output:** 2
+
+**Explanation:**
+
+One way to make the array alternating is by converting it to [1,2,**1**,2,**1**].
+
+The number of operations required in this case is 2.
+
+Note that the array cannot be converted to [**2**,2,2,2,2] because in this case nums[0] == nums[1] which violates the conditions of an alternating array.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* 1 <= nums[i] <= 105
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minimumOperations(nums: IntArray): Int {
+ var maxOdd = 0
+ var maxEven = 0
+ var max = 0
+ val n = nums.size
+ for (num in nums) {
+ max = Math.max(max, num)
+ }
+ val even = IntArray(max + 1)
+ val odd = IntArray(max + 1)
+ for (i in 0 until n) {
+ if (i % 2 == 0) {
+ even[nums[i]]++
+ } else {
+ odd[nums[i]]++
+ }
+ }
+ var t1 = 0
+ var t2 = 0
+ for (i in 0 until max + 1) {
+ if (even[i] > maxEven) {
+ maxEven = even[i]
+ t1 = i
+ }
+ if (odd[i] > maxOdd) {
+ maxOdd = odd[i]
+ t2 = i
+ }
+ }
+ val ans: Int
+ if (t1 == t2) {
+ var secondEven = 0
+ var secondOdd = 0
+ for (i in 0 until max + 1) {
+ if (i != t1 && even[i] > secondEven) {
+ secondEven = even[i]
+ }
+ if (i != t2 && odd[i] > secondOdd) {
+ secondOdd = odd[i]
+ }
+ }
+ ans = Math.min(
+ n / 2 + n % 2 - maxEven + (n / 2 - secondOdd),
+ n / 2 + n % 2 - secondEven + (n / 2 - maxOdd)
+ )
+ } else {
+ ans = n / 2 + n % 2 - maxEven + n / 2 - maxOdd
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2171_removing_minimum_number_of_magic_beans/readme.md b/src/main/kotlin/g2101_2200/s2171_removing_minimum_number_of_magic_beans/readme.md
new file mode 100644
index 00000000..40138925
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2171_removing_minimum_number_of_magic_beans/readme.md
@@ -0,0 +1,93 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2171\. Removing Minimum Number of Magic Beans
+
+Medium
+
+You are given an array of **positive** integers `beans`, where each integer represents the number of magic beans found in a particular magic bag.
+
+**Remove** any number of beans (**possibly none**) from each bag such that the number of beans in each remaining **non-empty** bag (still containing **at least one** bean) is **equal**. Once a bean has been removed from a bag, you are **not** allowed to return it to any of the bags.
+
+Return _the **minimum** number of magic beans that you have to remove_.
+
+**Example 1:**
+
+**Input:** beans = [4,**1**,6,5]
+
+**Output:** 4
+
+**Explanation:**
+
+- We remove 1 bean from the bag with only 1 bean.
+
+ This results in the remaining bags: [4,**0**,6,5]
+
+- Then we remove 2 beans from the bag with 6 beans.
+
+ This results in the remaining bags: [4,0,**4**,5]
+
+- Then we remove 1 bean from the bag with 5 beans.
+
+ This results in the remaining bags: [4,0,4,**4**]
+
+We removed a total of 1 + 2 + 1 = 4 beans to make the remaining non-empty bags have an equal number of beans.
+
+There are no other solutions that remove 4 beans or fewer.
+
+**Example 2:**
+
+**Input:** beans = [**2**,10,**3**,**2**]
+
+**Output:** 7
+
+**Explanation:**
+
+- We remove 2 beans from one of the bags with 2 beans.
+
+ This results in the remaining bags: [**0**,10,3,2]
+
+- Then we remove 2 beans from the other bag with 2 beans.
+
+ This results in the remaining bags: [0,10,3,**0**]
+
+- Then we remove 3 beans from the bag with 3 beans.
+
+ This results in the remaining bags: [0,10,**0**,0]
+
+We removed a total of 2 + 2 + 3 = 7 beans to make the remaining non-empty bags have an equal number of beans.
+
+There are no other solutions that removes 7 beans or fewer.
+
+**Constraints:**
+
+* 1 <= beans.length <= 105
+* 1 <= beans[i] <= 105
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minimumRemoval(beans: IntArray): Long {
+ beans.sort()
+ val n = beans.size
+ var sum: Long = 0
+ for (bean in beans) {
+ sum += bean.toLong()
+ }
+ var minbeans = Long.MAX_VALUE
+ var prefix: Long = 0
+ var suffix: Long
+ var count: Long
+ for (i in 0 until n) {
+ prefix += beans[i].toLong()
+ suffix = sum - prefix
+ count = prefix - beans[i] + (suffix - beans[i] * (n - i - 1L))
+ if (count < minbeans) {
+ minbeans = count
+ }
+ }
+ return minbeans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2172_maximum_and_sum_of_array/readme.md b/src/main/kotlin/g2101_2200/s2172_maximum_and_sum_of_array/readme.md
new file mode 100644
index 00000000..26b3e4bd
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2172_maximum_and_sum_of_array/readme.md
@@ -0,0 +1,77 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2172\. Maximum AND Sum of Array
+
+Hard
+
+You are given an integer array `nums` of length `n` and an integer `numSlots` such that `2 * numSlots >= n`. There are `numSlots` slots numbered from `1` to `numSlots`.
+
+You have to place all `n` integers into the slots such that each slot contains at **most** two numbers. The **AND sum** of a given placement is the sum of the **bitwise** `AND` of every number with its respective slot number.
+
+* For example, the **AND sum** of placing the numbers `[1, 3]` into slot `1` and `[4, 6]` into slot `2` is equal to `(1 AND 1) + (3 AND 1) + (4 AND 2) + (6 AND 2) = 1 + 1 + 0 + 2 = 4`.
+
+Return _the maximum possible **AND sum** of_ `nums` _given_ `numSlots` _slots._
+
+**Example 1:**
+
+**Input:** nums = [1,2,3,4,5,6], numSlots = 3
+
+**Output:** 9
+
+**Explanation:** One possible placement is [1, 4] into slot 1, [2, 6] into slot 2, and [3, 5] into slot 3.
+
+This gives the maximum AND sum of (1 AND 1) + (4 AND 1) + (2 AND 2) + (6 AND 2) + (3 AND 3) + (5 AND 3) = 1 + 0 + 2 + 2 + 3 + 1 = 9.
+
+**Example 2:**
+
+**Input:** nums = [1,3,10,4,7,1], numSlots = 9
+
+**Output:** 24
+
+**Explanation:** One possible placement is [1, 1] into slot 1, [3] into slot 3, [4] into slot 4, [7] into slot 7, and [10] into slot 9.
+
+This gives the maximum AND sum of (1 AND 1) + (1 AND 1) + (3 AND 3) + (4 AND 4) + (7 AND 7) + (10 AND 9) = 1 + 1 + 3 + 4 + 7 + 8 = 24.
+
+Note that slots 2, 5, 6, and 8 are empty which is permitted.
+
+**Constraints:**
+
+* `n == nums.length`
+* `1 <= numSlots <= 9`
+* `1 <= n <= 2 * numSlots`
+* `1 <= nums[i] <= 15`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun maximumANDSum(nums: IntArray, numSlots: Int): Int {
+ val mask = Math.pow(3.0, numSlots.toDouble()).toInt() - 1
+ val memo = IntArray(mask + 1)
+ return dp(nums.size - 1, mask, numSlots, memo, nums)
+ }
+
+ private fun dp(i: Int, mask: Int, numSlots: Int, memo: IntArray, ints: IntArray): Int {
+ if (memo[mask] > 0) {
+ return memo[mask]
+ }
+ if (i < 0) {
+ return 0
+ }
+ var slot = 1
+ var bit = 1
+ while (slot <= numSlots) {
+ if (mask / bit % 3 > 0) {
+ memo[mask] = Math.max(
+ memo[mask],
+ (ints[i] and slot) + dp(i - 1, mask - bit, numSlots, memo, ints)
+ )
+ }
+ ++slot
+ bit *= 3
+ }
+ return memo[mask]
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2176_count_equal_and_divisible_pairs_in_an_array/readme.md b/src/main/kotlin/g2101_2200/s2176_count_equal_and_divisible_pairs_in_an_array/readme.md
new file mode 100644
index 00000000..618b4fd0
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2176_count_equal_and_divisible_pairs_in_an_array/readme.md
@@ -0,0 +1,55 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2176\. Count Equal and Divisible Pairs in an Array
+
+Easy
+
+Given a **0-indexed** integer array `nums` of length `n` and an integer `k`, return _the **number of pairs**_ `(i, j)` _where_ `0 <= i < j < n`, _such that_ `nums[i] == nums[j]` _and_ `(i * j)` _is divisible by_ `k`.
+
+**Example 1:**
+
+**Input:** nums = [3,1,2,2,2,1,3], k = 2
+
+**Output:** 4
+
+**Explanation:** There are 4 pairs that meet all the requirements:
+
+- nums[0] == nums[6], and 0 \* 6 == 0, which is divisible by 2.
+
+- nums[2] == nums[3], and 2 \* 3 == 6, which is divisible by 2.
+
+- nums[2] == nums[4], and 2 \* 4 == 8, which is divisible by 2.
+
+- nums[3] == nums[4], and 3 \* 4 == 12, which is divisible by 2.
+
+**Example 2:**
+
+**Input:** nums = [1,2,3,4], k = 1
+
+**Output:** 0
+
+**Explanation:** Since no value in nums is repeated, there are no pairs (i,j) that meet all the requirements.
+
+**Constraints:**
+
+* `1 <= nums.length <= 100`
+* `1 <= nums[i], k <= 100`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun countPairs(nums: IntArray, k: Int): Int {
+ var ans = 0
+ for (i in nums.indices) {
+ for (j in i + 1 until nums.size) {
+ if (nums[i] == nums[j] && i * j % k == 0) {
+ ++ans
+ }
+ }
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2177_find_three_consecutive_integers_that_sum_to_a_given_number/readme.md b/src/main/kotlin/g2101_2200/s2177_find_three_consecutive_integers_that_sum_to_a_given_number/readme.md
new file mode 100644
index 00000000..e105b610
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2177_find_three_consecutive_integers_that_sum_to_a_given_number/readme.md
@@ -0,0 +1,42 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2177\. Find Three Consecutive Integers That Sum to a Given Number
+
+Medium
+
+Given an integer `num`, return _three consecutive integers (as a sorted array)_ _that **sum** to_ `num`. If `num` cannot be expressed as the sum of three consecutive integers, return _an **empty** array._
+
+**Example 1:**
+
+**Input:** num = 33
+
+**Output:** [10,11,12]
+
+**Explanation:** 33 can be expressed as 10 + 11 + 12 = 33.
+
+10, 11, 12 are 3 consecutive integers, so we return [10, 11, 12].
+
+**Example 2:**
+
+**Input:** num = 4
+
+**Output:** []
+
+**Explanation:** There is no way to express 4 as the sum of 3 consecutive integers.
+
+**Constraints:**
+
+* 0 <= num <= 1015
+
+## Solution
+
+```kotlin
+class Solution {
+ fun sumOfThree(num: Long): LongArray {
+ return if (num % 3 == 0L) {
+ longArrayOf(num / 3 - 1, num / 3, num / 3 + 1)
+ } else LongArray(0)
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2178_maximum_split_of_positive_even_integers/readme.md b/src/main/kotlin/g2101_2200/s2178_maximum_split_of_positive_even_integers/readme.md
new file mode 100644
index 00000000..3c95ce99
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2178_maximum_split_of_positive_even_integers/readme.md
@@ -0,0 +1,81 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2178\. Maximum Split of Positive Even Integers
+
+Medium
+
+You are given an integer `finalSum`. Split it into a sum of a **maximum** number of **unique** positive even integers.
+
+* For example, given `finalSum = 12`, the following splits are **valid** (unique positive even integers summing up to `finalSum`): `(12)`, `(2 + 10)`, `(2 + 4 + 6)`, and `(4 + 8)`. Among them, `(2 + 4 + 6)` contains the maximum number of integers. Note that `finalSum` cannot be split into `(2 + 2 + 4 + 4)` as all the numbers should be unique.
+
+Return _a list of integers that represent a valid split containing a **maximum** number of integers_. If no valid split exists for `finalSum`, return _an **empty** list_. You may return the integers in **any** order.
+
+**Example 1:**
+
+**Input:** finalSum = 12
+
+**Output:** [2,4,6]
+
+**Explanation:** The following are valid splits: `(12)`, `(2 + 10)`, `(2 + 4 + 6)`, and `(4 + 8)`.
+
+(2 + 4 + 6) has the maximum number of integers, which is 3. Thus, we return [2,4,6].
+
+Note that [2,6,4], [6,2,4], etc. are also accepted.
+
+**Example 2:**
+
+**Input:** finalSum = 7
+
+**Output:** []
+
+**Explanation:** There are no valid splits for the given finalSum. Thus, we return an empty array.
+
+**Example 3:**
+
+**Input:** finalSum = 28
+
+**Output:** [6,8,2,12]
+
+**Explanation:** The following are valid splits: `(2 + 26)`, `(6 + 8 + 2 + 12)`, and `(4 + 24)`.
+
+`(6 + 8 + 2 + 12)` has the maximum number of integers, which is 4. Thus, we return [6,8,2,12].
+
+Note that [10,2,4,12], [6,2,4,16], etc. are also accepted.
+
+**Constraints:**
+
+* 1 <= finalSum <= 1010
+
+## Solution
+
+```kotlin
+class Solution {
+ fun maximumEvenSplit(finalSum: Long): List {
+ var curr: Long = 2
+ var remainingSum = finalSum
+ val result: MutableList = ArrayList()
+ if (finalSum % 2 != 0L) {
+ return result
+ }
+ while (remainingSum >= curr) {
+ result.add(curr)
+ remainingSum -= curr
+ curr += 2
+ }
+ /*
+ go greedily by starting from smallest even number
+ for target = 16 after the while loop
+ remainingSum = 4
+ curr = 8 (if we add 8 it exceeds the target 16)
+ result = [2,4,6]
+ so remove 6 from list and add it to remainigSum and insert to list
+ result = [2,4,10]
+ */
+ val lastSum = result[result.size - 1]
+ result.removeAt(result.size - 1)
+ result.add(lastSum + remainingSum)
+ return result
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2179_count_good_triplets_in_an_array/readme.md b/src/main/kotlin/g2101_2200/s2179_count_good_triplets_in_an_array/readme.md
new file mode 100644
index 00000000..e3521730
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2179_count_good_triplets_in_an_array/readme.md
@@ -0,0 +1,99 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2179\. Count Good Triplets in an Array
+
+Hard
+
+You are given two **0-indexed** arrays `nums1` and `nums2` of length `n`, both of which are **permutations** of `[0, 1, ..., n - 1]`.
+
+A **good triplet** is a set of `3` **distinct** values which are present in **increasing order** by position both in `nums1` and `nums2`. In other words, if we consider pos1v as the index of the value `v` in `nums1` and pos2v as the index of the value `v` in `nums2`, then a good triplet will be a set `(x, y, z)` where `0 <= x, y, z <= n - 1`, such that pos1x < pos1y < pos1z and pos2x < pos2y < pos2z.
+
+Return _the **total number** of good triplets_.
+
+**Example 1:**
+
+**Input:** nums1 = [2,0,1,3], nums2 = [0,1,2,3]
+
+**Output:** 1
+
+**Explanation:**
+
+There are 4 triplets (x,y,z) such that pos1x < pos1y < pos1z. They are (2,0,1), (2,0,3), (2,1,3), and (0,1,3).
+
+Out of those triplets, only the triplet (0,1,3) satisfies pos2x < pos2y < pos2z.
+
+Hence, there is only 1 good triplet.
+
+**Example 2:**
+
+**Input:** nums1 = [4,0,1,3,2], nums2 = [4,1,0,2,3]
+
+**Output:** 4
+
+**Explanation:** The 4 good triplets are (4,0,3), (4,0,2), (4,1,3), and (4,1,2).
+
+**Constraints:**
+
+* `n == nums1.length == nums2.length`
+* 3 <= n <= 105
+* `0 <= nums1[i], nums2[i] <= n - 1`
+* `nums1` and `nums2` are permutations of `[0, 1, ..., n - 1]`.
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ fun goodTriplets(nums1: IntArray, nums2: IntArray): Long {
+ val n = nums1.size
+ val idx = IntArray(n)
+ val arr = IntArray(n)
+ for (i in 0 until n) {
+ idx[nums2[i]] = i
+ }
+ for (i in 0 until n) {
+ arr[i] = idx[nums1[i]]
+ }
+ val tree = Tree(n)
+ var res = 0L
+ for (i in 0 until n) {
+ val smaller = tree.query(arr[i])
+ val bigger = n - (arr[i] + 1) - (i - smaller)
+ res += smaller.toLong() * bigger
+ tree.update(arr[i] + 1, 1)
+ }
+ return res
+ }
+
+ private class Tree(var n: Int) {
+ var array: IntArray
+
+ init {
+ array = IntArray(n + 1)
+ }
+
+ fun lowbit(x: Int): Int {
+ return x and -x
+ }
+
+ fun update(i: Int, delta: Int) {
+ var i = i
+ while (i <= n) {
+ array[i] += delta
+ i += lowbit(i)
+ }
+ }
+
+ fun query(k: Int): Int {
+ var k = k
+ var ans = 0
+ while (k > 0) {
+ ans += array[k]
+ k -= lowbit(k)
+ }
+ return ans
+ }
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2180_count_integers_with_even_digit_sum/readme.md b/src/main/kotlin/g2101_2200/s2180_count_integers_with_even_digit_sum/readme.md
new file mode 100644
index 00000000..d1811d67
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2180_count_integers_with_even_digit_sum/readme.md
@@ -0,0 +1,50 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2180\. Count Integers With Even Digit Sum
+
+Easy
+
+Given a positive integer `num`, return _the number of positive integers **less than or equal to**_ `num` _whose digit sums are **even**_.
+
+The **digit sum** of a positive integer is the sum of all its digits.
+
+**Example 1:**
+
+**Input:** num = 4
+
+**Output:** 2
+
+**Explanation:**
+
+The only integers less than or equal to 4 whose digit sums are even are 2 and 4.
+
+**Example 2:**
+
+**Input:** num = 30
+
+**Output:** 14
+
+**Explanation:**
+
+The 14 integers less than or equal to 30 whose digit sums are even are
+
+2, 4, 6, 8, 11, 13, 15, 17, 19, 20, 22, 24, 26, and 28.
+
+**Constraints:**
+
+* `1 <= num <= 1000`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun countEven(num: Int): Int {
+ // Digit sum of the last number, we can get each digit this way sicne the range is [1, 1000]
+ val sum = num % 10 + num / 10 % 10 + num / 100 % 10 + num / 1000 % 10
+
+ // Check the parity of the digit sum of the last number
+ return (num - (sum and 1)) / 2
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2181_merge_nodes_in_between_zeros/readme.md b/src/main/kotlin/g2101_2200/s2181_merge_nodes_in_between_zeros/readme.md
new file mode 100644
index 00000000..db34cbf9
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2181_merge_nodes_in_between_zeros/readme.md
@@ -0,0 +1,91 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2181\. Merge Nodes in Between Zeros
+
+Medium
+
+You are given the `head` of a linked list, which contains a series of integers **separated** by `0`'s. The **beginning** and **end** of the linked list will have `Node.val == 0`.
+
+For **every** two consecutive `0`'s, **merge** all the nodes lying in between them into a single node whose value is the **sum** of all the merged nodes. The modified list should not contain any `0`'s.
+
+Return _the_ `head` _of the modified linked list_.
+
+**Example 1:**
+
+
+
+**Input:** head = [0,3,1,0,4,5,2,0]
+
+**Output:** [4,11]
+
+**Explanation:**
+
+The above figure represents the given linked list. The modified list contains
+
+- The sum of the nodes marked in green: 3 + 1 = 4.
+
+- The sum of the nodes marked in red: 4 + 5 + 2 = 11.
+
+**Example 2:**
+
+
+
+**Input:** head = [0,1,0,3,0,2,2,0]
+
+**Output:** [1,3,4]
+
+**Explanation:**
+
+The above figure represents the given linked list. The modified list contains
+
+- The sum of the nodes marked in green: 1 = 1.
+
+- The sum of the nodes marked in red: 3 = 3.
+
+- The sum of the nodes marked in yellow: 2 + 2 = 4.
+
+**Constraints:**
+
+* The number of nodes in the list is in the range [3, 2 * 105].
+* `0 <= Node.val <= 1000`
+* There are **no** two consecutive nodes with `Node.val == 0`.
+* The **beginning** and **end** of the linked list have `Node.val == 0`.
+
+## Solution
+
+```kotlin
+import com_github_leetcode.ListNode
+
+/*
+ * Example:
+ * var li = ListNode(5)
+ * var v = li.`val`
+ * Definition for singly-linked list.
+ * class ListNode(var `val`: Int) {
+ * var next: ListNode? = null
+ * }
+ */
+class Solution {
+ fun mergeNodes(head: ListNode): ListNode? {
+ var temp = head.next
+ var slow = head
+ var sum = 0
+ var fast = temp
+ while (temp != null) {
+ if (temp.`val` == 0) {
+ temp.`val` = sum
+ sum = 0
+ slow.next = fast!!.next
+ slow = temp
+ fast = fast.next
+ } else {
+ sum += temp.`val`
+ fast = temp
+ }
+ temp = temp.next
+ }
+ return head.next
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2182_construct_string_with_repeat_limit/readme.md b/src/main/kotlin/g2101_2200/s2182_construct_string_with_repeat_limit/readme.md
new file mode 100644
index 00000000..119f733d
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2182_construct_string_with_repeat_limit/readme.md
@@ -0,0 +1,97 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2182\. Construct String With Repeat Limit
+
+Medium
+
+You are given a string `s` and an integer `repeatLimit`. Construct a new string `repeatLimitedString` using the characters of `s` such that no letter appears **more than** `repeatLimit` times **in a row**. You do **not** have to use all characters from `s`.
+
+Return _the **lexicographically largest**_ `repeatLimitedString` _possible_.
+
+A string `a` is **lexicographically larger** than a string `b` if in the first position where `a` and `b` differ, string `a` has a letter that appears later in the alphabet than the corresponding letter in `b`. If the first `min(a.length, b.length)` characters do not differ, then the longer string is the lexicographically larger one.
+
+**Example 1:**
+
+**Input:** s = "cczazcc", repeatLimit = 3
+
+**Output:** "zzcccac"
+
+**Explanation:** We use all of the characters from s to construct the repeatLimitedString "zzcccac".
+
+The letter 'a' appears at most 1 time in a row.
+
+The letter 'c' appears at most 3 times in a row.
+
+The letter 'z' appears at most 2 times in a row.
+
+Hence, no letter appears more than repeatLimit times in a row and the string is a valid repeatLimitedString.
+
+The string is the lexicographically largest repeatLimitedString possible so we return "zzcccac".
+
+Note that the string "zzcccca" is lexicographically larger but the letter 'c' appears more than 3 times in a row, so it is not a valid repeatLimitedString.
+
+**Example 2:**
+
+**Input:** s = "aababab", repeatLimit = 2
+
+**Output:** "bbabaa"
+
+**Explanation:** We use only some of the characters from s to construct the repeatLimitedString "bbabaa".
+
+The letter 'a' appears at most 2 times in a row. The letter 'b' appears at most 2 times in a row.
+
+Hence, no letter appears more than repeatLimit times in a row and the string is a valid repeatLimitedString.
+
+The string is the lexicographically largest repeatLimitedString possible so we return "bbabaa".
+
+Note that the string "bbabaaa" is lexicographically larger but the letter 'a' appears more than 2 times in a row, so it is not a valid repeatLimitedString.
+
+**Constraints:**
+
+* 1 <= repeatLimit <= s.length <= 105
+* `s` consists of lowercase English letters.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun repeatLimitedString(s: String, repeatLimit: Int): String {
+ val result = CharArray(s.length)
+ val freq = IntArray(128)
+ var index = 0
+ for (c in s.toCharArray()) {
+ freq[c.code]++
+ }
+ var max = 'z'
+ var second = 'y'
+ while (true) {
+ while (max >= 'a' && freq[max.code] == 0) {
+ max--
+ }
+ if (max < 'a') {
+ break
+ }
+ second = Math.min(max.code - 1, second.code).toChar()
+ var count = Math.min(freq[max.code], repeatLimit)
+ freq[max.code] -= count
+ while (count-- > 0) {
+ result[index++] = max
+ }
+ if (freq[max.code] == 0) {
+ max = second--
+ continue
+ }
+ while (second >= 'a' && freq[second.code] == 0) {
+ second--
+ }
+ if (second < 'a') {
+ break
+ }
+ result[index++] = second
+ freq[second.code]--
+ }
+ return String(result, 0, index)
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2183_count_array_pairs_divisible_by_k/readme.md b/src/main/kotlin/g2101_2200/s2183_count_array_pairs_divisible_by_k/readme.md
new file mode 100644
index 00000000..f98ab428
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2183_count_array_pairs_divisible_by_k/readme.md
@@ -0,0 +1,71 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2183\. Count Array Pairs Divisible by K
+
+Hard
+
+Given a **0-indexed** integer array `nums` of length `n` and an integer `k`, return _the **number of pairs**_ `(i, j)` _such that:_
+
+* `0 <= i < j <= n - 1` _and_
+* `nums[i] * nums[j]` _is divisible by_ `k`.
+
+**Example 1:**
+
+**Input:** nums = [1,2,3,4,5], k = 2
+
+**Output:** 7
+
+**Explanation:**
+
+The 7 pairs of indices whose corresponding products are divisible by 2 are
+
+(0, 1), (0, 3), (1, 2), (1, 3), (1, 4), (2, 3), and (3, 4).
+
+Their products are 2, 4, 6, 8, 10, 12, and 20 respectively.
+
+Other pairs such as (0, 2) and (2, 4) have products 3 and 15 respectively, which are not divisible by 2.
+
+**Example 2:**
+
+**Input:** nums = [1,2,3,4], k = 5
+
+**Output:** 0
+
+**Explanation:** There does not exist any pair of indices whose corresponding product is divisible by 5.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* 1 <= nums[i], k <= 105
+
+## Solution
+
+```kotlin
+class Solution {
+ fun countPairs(nums: IntArray, k: Int): Long {
+ var count = 0L
+ val map: MutableMap = HashMap()
+ for (num in nums) {
+ val gd = gcd(num, k)
+ val want = k / gd
+ for ((key, value) in map) {
+ if (key % want == 0) {
+ count += value
+ }
+ }
+ map[gd] = map.getOrDefault(gd, 0L) + 1L
+ }
+ return count
+ }
+
+ private fun gcd(a: Int, b: Int): Int {
+ if (a > b) {
+ return gcd(b, a)
+ }
+ return if (a == 0) {
+ b
+ } else gcd(a, b % a)
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2185_counting_words_with_a_given_prefix/readme.md b/src/main/kotlin/g2101_2200/s2185_counting_words_with_a_given_prefix/readme.md
new file mode 100644
index 00000000..8db6f6d7
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2185_counting_words_with_a_given_prefix/readme.md
@@ -0,0 +1,50 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2185\. Counting Words With a Given Prefix
+
+Easy
+
+You are given an array of strings `words` and a string `pref`.
+
+Return _the number of strings in_ `words` _that contain_ `pref` _as a **prefix**_.
+
+A **prefix** of a string `s` is any leading contiguous substring of `s`.
+
+**Example 1:**
+
+**Input:** words = ["pay","**at**tention","practice","**at**tend"], `pref` \= "at"
+
+**Output:** 2
+
+**Explanation:** The 2 strings that contain "at" as a prefix are: "**at**tention" and "**at**tend".
+
+**Example 2:**
+
+**Input:** words = ["leetcode","win","loops","success"], `pref` \= "code"
+
+**Output:** 0
+
+**Explanation:** There are no strings that contain "code" as a prefix.
+
+**Constraints:**
+
+* `1 <= words.length <= 100`
+* `1 <= words[i].length, pref.length <= 100`
+* `words[i]` and `pref` consist of lowercase English letters.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun prefixCount(words: Array, pref: String?): Int {
+ var count = 0
+ for (s in words) {
+ if (s.startsWith(pref!!)) {
+ count++
+ }
+ }
+ return count
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2186_minimum_number_of_steps_to_make_two_strings_anagram_ii/readme.md b/src/main/kotlin/g2101_2200/s2186_minimum_number_of_steps_to_make_two_strings_anagram_ii/readme.md
new file mode 100644
index 00000000..66e069bb
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2186_minimum_number_of_steps_to_make_two_strings_anagram_ii/readme.md
@@ -0,0 +1,64 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2186\. Minimum Number of Steps to Make Two Strings Anagram II
+
+Medium
+
+You are given two strings `s` and `t`. In one step, you can append **any character** to either `s` or `t`.
+
+Return _the minimum number of steps to make_ `s` _and_ `t` _**anagrams** of each other._
+
+An **anagram** of a string is a string that contains the same characters with a different (or the same) ordering.
+
+**Example 1:**
+
+**Input:** s = "**lee**tco**de**", t = "co**a**t**s**"
+
+**Output:** 7
+
+**Explanation:**
+
+- In 2 steps, we can append the letters in "as" onto s = "leetcode", forming s = "leetcode**as**".
+
+- In 5 steps, we can append the letters in "leede" onto t = "coats", forming t = "coats**leede**".
+
+"leetcodeas" and "coatsleede" are now anagrams of each other.
+
+We used a total of 2 + 5 = 7 steps.
+
+It can be shown that there is no way to make them anagrams of each other with less than 7 steps.
+
+**Example 2:**
+
+**Input:** s = "night", t = "thing"
+
+**Output:** 0
+
+**Explanation:** The given strings are already anagrams of each other. Thus, we do not need any further steps.
+
+**Constraints:**
+
+* 1 <= s.length, t.length <= 2 * 105
+* `s` and `t` consist of lowercase English letters.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minSteps(s: String, t: String): Int {
+ val a = IntArray(26)
+ for (i in 0 until s.length) {
+ a[s[i].code - 'a'.code]++
+ }
+ for (i in 0 until t.length) {
+ a[t[i].code - 'a'.code]--
+ }
+ var sum = 0
+ for (j in a) {
+ sum += Math.abs(j)
+ }
+ return sum
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2187_minimum_time_to_complete_trips/readme.md b/src/main/kotlin/g2101_2200/s2187_minimum_time_to_complete_trips/readme.md
new file mode 100644
index 00000000..b11f9902
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2187_minimum_time_to_complete_trips/readme.md
@@ -0,0 +1,83 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2187\. Minimum Time to Complete Trips
+
+Medium
+
+You are given an array `time` where `time[i]` denotes the time taken by the ith bus to complete **one trip**.
+
+Each bus can make multiple trips **successively**; that is, the next trip can start **immediately after** completing the current trip. Also, each bus operates **independently**; that is, the trips of one bus do not influence the trips of any other bus.
+
+You are also given an integer `totalTrips`, which denotes the number of trips all buses should make **in total**. Return _the **minimum time** required for all buses to complete **at least**_ `totalTrips` _trips_.
+
+**Example 1:**
+
+**Input:** time = [1,2,3], totalTrips = 5
+
+**Output:** 3
+
+**Explanation:**
+
+- At time t = 1, the number of trips completed by each bus are [1,0,0].
+
+The total number of trips completed is 1 + 0 + 0 = 1.
+
+- At time t = 2, the number of trips completed by each bus are [2,1,0].
+
+The total number of trips completed is 2 + 1 + 0 = 3.
+
+- At time t = 3, the number of trips completed by each bus are [3,1,1].
+
+The total number of trips completed is 3 + 1 + 1 = 5.
+
+So the minimum time needed for all buses to complete at least 5 trips is 3.
+
+**Example 2:**
+
+**Input:** time = [2], totalTrips = 1
+
+**Output:** 2
+
+**Explanation:**
+
+There is only one bus, and it will complete its first trip at t = 2.
+
+So the minimum time needed to complete 1 trip is 2.
+
+**Constraints:**
+
+* 1 <= time.length <= 105
+* 1 <= time[i], totalTrips <= 107
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minimumTime(time: IntArray, totalTrips: Int): Long {
+ return bs(0, Long.MAX_VALUE, time, totalTrips.toLong())
+ }
+
+ private fun bs(left: Long, right: Long, time: IntArray, totalTrips: Long): Long {
+ if (left > right) {
+ return Long.MAX_VALUE
+ }
+ val mid = left + right shr 1
+ return if (isPossible(time, mid, totalTrips)) Math.min(
+ mid,
+ bs(left, mid - 1, time, totalTrips)
+ ) else bs(mid + 1, right, time, totalTrips)
+ }
+
+ private fun isPossible(time: IntArray, mid: Long, totalTrips: Long): Boolean {
+ var count: Long = 0
+ for (i in time) {
+ count += mid / i
+ if (count >= totalTrips) {
+ return true
+ }
+ }
+ return false
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2188_minimum_time_to_finish_the_race/readme.md b/src/main/kotlin/g2101_2200/s2188_minimum_time_to_finish_the_race/readme.md
new file mode 100644
index 00000000..25b44bad
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2188_minimum_time_to_finish_the_race/readme.md
@@ -0,0 +1,117 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2188\. Minimum Time to Finish the Race
+
+Hard
+
+You are given a **0-indexed** 2D integer array `tires` where tires[i] = [fi, ri] indicates that the ith tire can finish its xth successive lap in fi * ri(x-1) seconds.
+
+* For example, if fi = 3 and ri = 2, then the tire would finish its 1st lap in `3` seconds, its 2nd lap in `3 * 2 = 6` seconds, its 3rd lap in 3 * 22 = 12 seconds, etc.
+
+You are also given an integer `changeTime` and an integer `numLaps`.
+
+The race consists of `numLaps` laps and you may start the race with **any** tire. You have an **unlimited** supply of each tire and after every lap, you may **change** to any given tire (including the current tire type) if you wait `changeTime` seconds.
+
+Return _the **minimum** time to finish the race._
+
+**Example 1:**
+
+**Input:** tires = \[\[2,3],[3,4]], changeTime = 5, numLaps = 4
+
+**Output:** 21
+
+**Explanation:**
+
+Lap 1: Start with tire 0 and finish the lap in 2 seconds.
+
+Lap 2: Continue with tire 0 and finish the lap in 2 \* 3 = 6 seconds.
+
+Lap 3: Change tires to a new tire 0 for 5 seconds and then finish the lap in another 2 seconds.
+
+Lap 4: Continue with tire 0 and finish the lap in 2 \* 3 = 6 seconds.
+
+Total time = 2 + 6 + 5 + 2 + 6 = 21 seconds.
+
+The minimum time to complete the race is 21 seconds.
+
+**Example 2:**
+
+**Input:** tires = \[\[1,10],[2,2],[3,4]], changeTime = 6, numLaps = 5
+
+**Output:** 25
+
+**Explanation:**
+
+Lap 1: Start with tire 1 and finish the lap in 2 seconds.
+
+Lap 2: Continue with tire 1 and finish the lap in 2 \* 2 = 4 seconds.
+
+Lap 3: Change tires to a new tire 1 for 6 seconds and then finish the lap in another 2 seconds.
+
+Lap 4: Continue with tire 1 and finish the lap in 2 \* 2 = 4 seconds.
+
+Lap 5: Change tires to tire 0 for 6 seconds then finish the lap in another 1 second.
+
+Total time = 2 + 4 + 6 + 2 + 4 + 6 + 1 = 25 seconds.
+
+The minimum time to complete the race is 25 seconds.
+
+**Constraints:**
+
+* 1 <= tires.length <= 105
+* `tires[i].length == 2`
+* 1 <= fi, changeTime <= 105
+* 2 <= ri <= 105
+* `1 <= numLaps <= 1000`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minimumFinishTime(tires: Array, changeTime: Int, numLaps: Int): Int {
+ var minf = Int.MAX_VALUE
+ // find the minimum of f, to deal with special case and stronger constraints later.
+ for (tire in tires) {
+ minf = Math.min(minf, tire[0])
+ }
+ // if min-f >= changeTime, we can return early
+ if (minf >= changeTime) {
+ return minf * numLaps + changeTime * (numLaps - 1)
+ }
+ // shortest[i] record shortest time that one single tire is worth to go the i-th laps
+ // worth to go means the i-th lap time is shorter than changeTime + f
+ val shortest = IntArray(numLaps + 1)
+ shortest.fill(Int.MAX_VALUE)
+ var len = 0
+ // traverse all tires, and update the shortest[i]
+ // this shortest time is available from [1, len] in the array
+ // len is updated in the traverse
+ for (tire in tires) {
+ val f = tire[0]
+ val r = tire[1]
+ // index start from 1 to be consistent with numLaps
+ var index = 1
+ var t = f
+ var sum = t
+ // use changeTime + minf here, which is a strong constraints than changeTime + f
+ while (t <= changeTime + minf && index <= numLaps) {
+ shortest[index] = Math.min(shortest[index], sum)
+ t = t * r
+ sum += t
+ index++
+ }
+ len = Math.max(len, index - 1)
+ }
+ for (i in 2..numLaps) {
+ // for j > Math.min(i/2, len), it's simply recombination of the values of shortest
+ // [1:len]
+ // it's ok to go furthur for the loop, just repeat the Math.min computation
+ for (j in 1..Math.min(i / 2, len)) {
+ shortest[i] = Math.min(shortest[i], shortest[j] + shortest[i - j] + changeTime)
+ }
+ }
+ return shortest[numLaps]
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2190_most_frequent_number_following_key_in_an_array/readme.md b/src/main/kotlin/g2101_2200/s2190_most_frequent_number_following_key_in_an_array/readme.md
new file mode 100644
index 00000000..1deafbf5
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2190_most_frequent_number_following_key_in_an_array/readme.md
@@ -0,0 +1,68 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2190\. Most Frequent Number Following Key In an Array
+
+Easy
+
+You are given a **0-indexed** integer array `nums`. You are also given an integer `key`, which is present in `nums`.
+
+For every unique integer `target` in `nums`, **count** the number of times `target` immediately follows an occurrence of `key` in `nums`. In other words, count the number of indices `i` such that:
+
+* `0 <= i <= nums.length - 2`,
+* `nums[i] == key` and,
+* `nums[i + 1] == target`.
+
+Return _the_ `target` _with the **maximum** count_. The test cases will be generated such that the `target` with maximum count is unique.
+
+**Example 1:**
+
+**Input:** nums = [1,100,200,1,100], key = 1
+
+**Output:** 100
+
+**Explanation:** For target = 100, there are 2 occurrences at indices 1 and 4 which follow an occurrence of key.
+
+No other integers follow an occurrence of key, so we return 100.
+
+**Example 2:**
+
+**Input:** nums = [2,2,2,2,3], key = 2
+
+**Output:** 2
+
+**Explanation:** For target = 2, there are 3 occurrences at indices 1, 2, and 3 which follow an occurrence of key.
+
+For target = 3, there is only one occurrence at index 4 which follows an occurrence of key.
+
+target = 2 has the maximum number of occurrences following an occurrence of key, so we return 2.
+
+**Constraints:**
+
+* `2 <= nums.length <= 1000`
+* `1 <= nums[i] <= 1000`
+* The test cases will be generated such that the answer is unique.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun mostFrequent(nums: IntArray, key: Int): Int {
+ val store = IntArray(1001)
+ for (i in 0 until nums.size - 1) {
+ if (nums[i] == key) {
+ store[nums[i + 1]]++
+ }
+ }
+ var res = 0
+ var count = store[0]
+ for (i in 1..1000) {
+ if (count < store[i]) {
+ count = store[i]
+ res = i
+ }
+ }
+ return res
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2191_sort_the_jumbled_numbers/readme.md b/src/main/kotlin/g2101_2200/s2191_sort_the_jumbled_numbers/readme.md
new file mode 100644
index 00000000..db1f75b8
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2191_sort_the_jumbled_numbers/readme.md
@@ -0,0 +1,110 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2191\. Sort the Jumbled Numbers
+
+Medium
+
+You are given a **0-indexed** integer array `mapping` which represents the mapping rule of a shuffled decimal system. `mapping[i] = j` means digit `i` should be mapped to digit `j` in this system.
+
+The **mapped value** of an integer is the new integer obtained by replacing each occurrence of digit `i` in the integer with `mapping[i]` for all `0 <= i <= 9`.
+
+You are also given another integer array `nums`. Return _the array_ `nums` _sorted in **non-decreasing** order based on the **mapped values** of its elements._
+
+**Notes:**
+
+* Elements with the same mapped values should appear in the **same relative order** as in the input.
+* The elements of `nums` should only be sorted based on their mapped values and **not be replaced** by them.
+
+**Example 1:**
+
+**Input:** mapping = [8,9,4,0,2,1,3,5,7,6], nums = [991,338,38]
+
+**Output:** [338,38,991]
+
+**Explanation:**
+
+Map the number 991 as follows:
+
+1. mapping[9] = 6, so all occurrences of the digit 9 will become 6.
+
+2. mapping[1] = 9, so all occurrences of the digit 1 will become 9.
+
+Therefore, the mapped value of 991 is 669.
+
+338 maps to 007, or 7 after removing the leading zeros.
+
+38 maps to 07, which is also 7 after removing leading zeros.
+
+Since 338 and 38 share the same mapped value, they should remain in the same relative order, so 338 comes before 38.
+
+Thus, the sorted array is [338,38,991].
+
+**Example 2:**
+
+**Input:** mapping = [0,1,2,3,4,5,6,7,8,9], nums = [789,456,123]
+
+**Output:** [123,456,789]
+
+**Explanation:** 789 maps to 789, 456 maps to 456, and 123 maps to 123. Thus, the sorted array is [123,456,789].
+
+**Constraints:**
+
+* `mapping.length == 10`
+* `0 <= mapping[i] <= 9`
+* All the values of `mapping[i]` are **unique**.
+* 1 <= nums.length <= 3 * 104
+* 0 <= nums[i] < 109
+
+## Solution
+
+```kotlin
+import java.util.Collections
+
+class Solution {
+ @Suppress("NAME_SHADOWING")
+ private class RealNum(mapping: IntArray, orig: Int, index: Int) {
+ var index: Int
+ var orig: Int
+ var real = 0
+
+ init {
+ var orig = orig
+ this.orig = orig
+ this.index = index
+ var mult = 1
+ if (orig == 0) {
+ real = mapping[0]
+ } else {
+ while (orig > 0) {
+ val mod = orig % 10
+ orig = orig / 10
+ real += mapping[mod] * mult
+ mult *= 10
+ }
+ }
+ }
+ }
+
+ fun sortJumbled(mapping: IntArray, nums: IntArray): IntArray {
+ val realNums: MutableList = ArrayList()
+ for (i in nums.indices) {
+ val num = nums[i]
+ val realNum = RealNum(mapping, num, i)
+ realNums.add(realNum)
+ }
+ Collections.sort(realNums) { a: RealNum, b: RealNum ->
+ val retval = a.real - b.real
+ if (retval != 0) {
+ return@sort retval
+ }
+ a.index - b.index
+ }
+ val retval = IntArray(nums.size)
+ for (i in nums.indices) {
+ retval[i] = realNums[i].orig
+ }
+ return retval
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2192_all_ancestors_of_a_node_in_a_directed_acyclic_graph/readme.md b/src/main/kotlin/g2101_2200/s2192_all_ancestors_of_a_node_in_a_directed_acyclic_graph/readme.md
new file mode 100644
index 00000000..cc255430
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2192_all_ancestors_of_a_node_in_a_directed_acyclic_graph/readme.md
@@ -0,0 +1,122 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2192\. All Ancestors of a Node in a Directed Acyclic Graph
+
+Medium
+
+You are given a positive integer `n` representing the number of nodes of a **Directed Acyclic Graph** (DAG). The nodes are numbered from `0` to `n - 1` (**inclusive**).
+
+You are also given a 2D integer array `edges`, where edges[i] = [fromi, toi] denotes that there is a **unidirectional** edge from fromi to toi in the graph.
+
+Return _a list_ `answer`_, where_ `answer[i]` _is the **list of ancestors** of the_ ith _node, sorted in **ascending order**_.
+
+A node `u` is an **ancestor** of another node `v` if `u` can reach `v` via a set of edges.
+
+**Example 1:**
+
+
+
+**Input:** n = 8, edgeList = \[\[0,3],[0,4],[1,3],[2,4],[2,7],[3,5],[3,6],[3,7],[4,6]]
+
+**Output:** [[],[],[],[0,1],[0,2],[0,1,3],[0,1,2,3,4],[0,1,2,3]]
+
+**Explanation:**
+
+The above diagram represents the input graph.
+
+- Nodes 0, 1, and 2 do not have any ancestors.
+
+- Node 3 has two ancestors 0 and 1.
+
+- Node 4 has two ancestors 0 and 2.
+
+- Node 5 has three ancestors 0, 1, and 3.
+
+- Node 6 has five ancestors 0, 1, 2, 3, and 4.
+
+- Node 7 has four ancestors 0, 1, 2, and 3.
+
+**Example 2:**
+
+
+
+**Input:** n = 5, edgeList = \[\[0,1],[0,2],[0,3],[0,4],[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
+
+**Output:** [[],[0],[0,1],[0,1,2],[0,1,2,3]]
+
+**Explanation:**
+
+The above diagram represents the input graph.
+
+- Node 0 does not have any ancestor.
+
+- Node 1 has one ancestor 0.
+
+- Node 2 has two ancestors 0 and 1.
+
+- Node 3 has three ancestors 0, 1, and 2.
+
+- Node 4 has four ancestors 0, 1, 2, and 3.
+
+**Constraints:**
+
+* `1 <= n <= 1000`
+* `0 <= edges.length <= min(2000, n * (n - 1) / 2)`
+* `edges[i].length == 2`
+* 0 <= fromi, toi <= n - 1
+* fromi != toi
+* There are no duplicate edges.
+* The graph is **directed** and **acyclic**.
+
+## Solution
+
+```kotlin
+class Solution {
+ private lateinit var adjList: MutableList>
+ private lateinit var result: MutableList>
+
+ fun getAncestors(n: Int, edges: Array): List> {
+ adjList = ArrayList()
+ result = ArrayList()
+ for (i in 0 until n) {
+ adjList.add(ArrayList())
+ result.add(ArrayList())
+ }
+ for (edge in edges) {
+ val start = edge[0]
+ val end = edge[1]
+ adjList[start].add(end)
+ }
+ // DFS for each node from 0 --> n , and add that node as root/parent into each reachable
+ // node and their child
+ // Use visited[] to identify if any of the child or their childs are already visited for
+ // that perticular root/parent,
+ // so will not add the root to avoid duplicacy and call reduction .
+ for (i in 0 until n) {
+ val visited = BooleanArray(n)
+ val childList: List = adjList[i]
+ for (child in childList) {
+ if (!visited[child]) {
+ dfs(i, child, visited)
+ }
+ }
+ }
+ return result
+ }
+
+ private fun dfs(root: Int, node: Int, visited: BooleanArray) {
+ if (visited[node]) {
+ return
+ }
+ visited[node] = true
+ result[node].add(root)
+ val childList: List = adjList[node]
+ for (child in childList) {
+ if (!visited[child]) {
+ dfs(root, child, visited)
+ }
+ }
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2193_minimum_number_of_moves_to_make_palindrome/readme.md b/src/main/kotlin/g2101_2200/s2193_minimum_number_of_moves_to_make_palindrome/readme.md
new file mode 100644
index 00000000..018b024f
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2193_minimum_number_of_moves_to_make_palindrome/readme.md
@@ -0,0 +1,91 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2193\. Minimum Number of Moves to Make Palindrome
+
+Hard
+
+You are given a string `s` consisting only of lowercase English letters.
+
+In one **move**, you can select any two **adjacent** characters of `s` and swap them.
+
+Return _the **minimum number of moves** needed to make_ `s` _a palindrome_.
+
+**Note** that the input will be generated such that `s` can always be converted to a palindrome.
+
+**Example 1:**
+
+**Input:** s = "aabb"
+
+**Output:** 2
+
+**Explanation:**
+
+We can obtain two palindromes from s, "abba" and "baab".
+
+- We can obtain "abba" from s in 2 moves: "a**ab**b" -> "ab**ab**" -> "abba".
+
+- We can obtain "baab" from s in 2 moves: "a**ab**b" -> "**ab**ab" -> "baab".
+
+Thus, the minimum number of moves needed to make s a palindrome is 2.
+
+**Example 2:**
+
+**Input:** s = "letelt"
+
+**Output:** 2
+
+**Explanation:**
+
+One of the palindromes we can obtain from s in 2 moves is "lettel".
+
+One of the ways we can obtain it is "lete**lt**" -> "let**et**l" -> "lettel".
+
+Other palindromes such as "tleelt" can also be obtained in 2 moves.
+
+It can be shown that it is not possible to obtain a palindrome in less than 2 moves.
+
+**Constraints:**
+
+* `1 <= s.length <= 2000`
+* `s` consists only of lowercase English letters.
+* `s` can be converted to a palindrome using a finite number of moves.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minMovesToMakePalindrome(s: String): Int {
+ var l = 0
+ var r = s.length - 1
+ val charArray = s.toCharArray()
+ var output = 0
+ while (l < r) {
+ if (charArray[l] != charArray[r]) {
+ val prev = charArray[l]
+ var k = r
+ while (charArray[k] != prev) {
+ k--
+ }
+ // middle element
+ if (k == l) {
+ val temp = charArray[l]
+ charArray[l] = charArray[l + 1]
+ charArray[l + 1] = temp
+ output++
+ continue
+ }
+ for (i in k until r) {
+ val temp = charArray[i]
+ charArray[i] = charArray[i + 1]
+ charArray[i + 1] = temp
+ output++
+ }
+ }
+ l++
+ r--
+ }
+ return output
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2194_cells_in_a_range_on_an_excel_sheet/readme.md b/src/main/kotlin/g2101_2200/s2194_cells_in_a_range_on_an_excel_sheet/readme.md
new file mode 100644
index 00000000..9acf7381
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2194_cells_in_a_range_on_an_excel_sheet/readme.md
@@ -0,0 +1,72 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2194\. Cells in a Range on an Excel Sheet
+
+Easy
+
+A cell `(r, c)` of an excel sheet is represented as a string `""` where:
+
+* `` denotes the column number `c` of the cell. It is represented by **alphabetical letters**.
+ * For example, the 1st column is denoted by `'A'`, the 2nd by `'B'`, the 3rd by `'C'`, and so on.
+* `` is the row number `r` of the cell. The rth row is represented by the **integer** `r`.
+
+You are given a string `s` in the format `":"`, where `` represents the column `c1`, `` represents the row `r1`, `` represents the column `c2`, and `` represents the row `r2`, such that `r1 <= r2` and `c1 <= c2`.
+
+Return _the **list of cells**_ `(x, y)` _such that_ `r1 <= x <= r2` _and_ `c1 <= y <= c2`. The cells should be represented as **strings** in the format mentioned above and be sorted in **non-decreasing** order first by columns and then by rows.
+
+**Example 1:**
+
+
+
+**Input:** s = "K1:L2"
+
+**Output:** ["K1","K2","L1","L2"]
+
+**Explanation:**
+
+The above diagram shows the cells which should be present in the list.
+
+The red arrows denote the order in which the cells should be presented.
+
+**Example 2:**
+
+
+
+**Input:** s = "A1:F1"
+
+**Output:** ["A1","B1","C1","D1","E1","F1"]
+
+**Explanation:**
+
+The above diagram shows the cells which should be present in the list.
+
+The red arrow denotes the order in which the cells should be presented.
+
+**Constraints:**
+
+* `s.length == 5`
+* `'A' <= s[0] <= s[3] <= 'Z'`
+* `'1' <= s[1] <= s[4] <= '9'`
+* `s` consists of uppercase English letters, digits and `':'`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun cellsInRange(s: String): List {
+ val c = s.toCharArray()
+ val strings: MutableList = ArrayList()
+ var i = c[0]
+ while (i <= c[3]) {
+ var j = c[1]
+ while (j <= c[4]) {
+ strings.add(String(charArrayOf(i, j)))
+ j++
+ }
+ i++
+ }
+ return strings
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2195_append_k_integers_with_minimal_sum/readme.md b/src/main/kotlin/g2101_2200/s2195_append_k_integers_with_minimal_sum/readme.md
new file mode 100644
index 00000000..6d6f347b
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2195_append_k_integers_with_minimal_sum/readme.md
@@ -0,0 +1,63 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2195\. Append K Integers With Minimal Sum
+
+Medium
+
+You are given an integer array `nums` and an integer `k`. Append `k` **unique positive** integers that do **not** appear in `nums` to `nums` such that the resulting total sum is **minimum**.
+
+Return _the sum of the_ `k` _integers appended to_ `nums`.
+
+**Example 1:**
+
+**Input:** nums = [1,4,25,10,25], k = 2
+
+**Output:** 5
+
+**Explanation:** The two unique positive integers that do not appear in nums which we append are 2 and 3.
+
+The resulting sum of nums is 1 + 4 + 25 + 10 + 25 + 2 + 3 = 70, which is the minimum.
+
+The sum of the two integers appended is 2 + 3 = 5, so we return 5.
+
+**Example 2:**
+
+**Input:** nums = [5,6], k = 6
+
+**Output:** 25
+
+**Explanation:** The six unique positive integers that do not appear in nums which we append are 1, 2, 3, 4, 7, and 8.
+
+The resulting sum of nums is 5 + 6 + 1 + 2 + 3 + 4 + 7 + 8 = 36, which is the minimum.
+
+The sum of the six integers appended is 1 + 2 + 3 + 4 + 7 + 8 = 25, so we return 25.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* 1 <= nums[i] <= 109
+* 1 <= k <= 108
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minimalKSum(nums: IntArray, k: Int): Long {
+ nums.sort()
+ var sum: Long = 0
+ var n = 0
+ for (i in nums.indices) {
+ if (i == 0 || nums[i] != nums[i - 1]) {
+ if (nums[i] - n > k) {
+ break
+ }
+ sum += nums[i].toLong()
+ n++
+ }
+ }
+ val t = n + k.toLong()
+ return (1 + t) * t / 2 - sum
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2196_create_binary_tree_from_descriptions/readme.md b/src/main/kotlin/g2101_2200/s2196_create_binary_tree_from_descriptions/readme.md
new file mode 100644
index 00000000..e5fd2702
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2196_create_binary_tree_from_descriptions/readme.md
@@ -0,0 +1,101 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2196\. Create Binary Tree From Descriptions
+
+Medium
+
+You are given a 2D integer array `descriptions` where descriptions[i] = [parenti, childi, isLefti] indicates that parenti is the **parent** of childi in a **binary** tree of **unique** values. Furthermore,
+
+* If isLefti == 1, then childi is the left child of parenti.
+* If isLefti == 0, then childi is the right child of parenti.
+
+Construct the binary tree described by `descriptions` and return _its **root**_.
+
+The test cases will be generated such that the binary tree is **valid**.
+
+**Example 1:**
+
+
+
+**Input:** descriptions = \[\[20,15,1],[20,17,0],[50,20,1],[50,80,0],[80,19,1]]
+
+**Output:** [50,20,80,15,17,19]
+
+**Explanation:** The root node is the node with value 50 since it has no parent.
+
+The resulting binary tree is shown in the diagram.
+
+**Example 2:**
+
+
+
+**Input:** descriptions = \[\[1,2,1],[2,3,0],[3,4,1]]
+
+**Output:** [1,2,null,null,3,4]
+
+**Explanation:** The root node is the node with value 1 since it has no parent.
+
+The resulting binary tree is shown in the diagram.
+
+**Constraints:**
+
+* 1 <= descriptions.length <= 104
+* `descriptions[i].length == 3`
+* 1 <= parenti, childi <= 105
+* 0 <= isLefti <= 1
+* The binary tree described by `descriptions` is valid.
+
+## Solution
+
+```kotlin
+import com_github_leetcode.TreeNode
+
+/*
+ * Example:
+ * var ti = TreeNode(5)
+ * var v = ti.`val`
+ * Definition for a binary tree node.
+ * class TreeNode(var `val`: Int) {
+ * var left: TreeNode? = null
+ * var right: TreeNode? = null
+ * }
+ */
+class Solution {
+ fun createBinaryTree(descriptions: Array): TreeNode? {
+ val map: MutableMap = HashMap()
+ for (description in descriptions) {
+ var data = map[description[0]]
+ if (data == null) {
+ data = Data()
+ data.node = TreeNode(description[0])
+ data.isHead = true
+ map[description[0]] = data
+ }
+ var childData = map[description[1]]
+ if (childData == null) {
+ childData = Data()
+ childData.node = TreeNode(description[1])
+ map[childData.node!!.`val`] = childData
+ }
+ childData.isHead = false
+ if (description[2] == 1) {
+ data.node!!.left = childData.node
+ } else {
+ data.node!!.right = childData.node
+ }
+ }
+ for ((_, value) in map) {
+ if (value.isHead) {
+ return value.node
+ }
+ }
+ return null
+ }
+
+ private class Data {
+ var node: TreeNode? = null
+ var isHead = false
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2197_replace_non_coprime_numbers_in_array/readme.md b/src/main/kotlin/g2101_2200/s2197_replace_non_coprime_numbers_in_array/readme.md
new file mode 100644
index 00000000..3b94caed
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2197_replace_non_coprime_numbers_in_array/readme.md
@@ -0,0 +1,122 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2197\. Replace Non-Coprime Numbers in Array
+
+Hard
+
+You are given an array of integers `nums`. Perform the following steps:
+
+1. Find **any** two **adjacent** numbers in `nums` that are **non-coprime**.
+2. If no such numbers are found, **stop** the process.
+3. Otherwise, delete the two numbers and **replace** them with their **LCM (Least Common Multiple)**.
+4. **Repeat** this process as long as you keep finding two adjacent non-coprime numbers.
+
+Return _the **final** modified array._ It can be shown that replacing adjacent non-coprime numbers in **any** arbitrary order will lead to the same result.
+
+The test cases are generated such that the values in the final array are **less than or equal** to 108.
+
+Two values `x` and `y` are **non-coprime** if `GCD(x, y) > 1` where `GCD(x, y)` is the **Greatest Common Divisor** of `x` and `y`.
+
+**Example 1:**
+
+**Input:** nums = [6,4,3,2,7,6,2]
+
+**Output:** [12,7,6]
+
+**Explanation:**
+
+- (6, 4) are non-coprime with LCM(6, 4) = 12. Now, nums = [**12**,3,2,7,6,2].
+
+- (12, 3) are non-coprime with LCM(12, 3) = 12. Now, nums = [**12**,2,7,6,2].
+
+- (12, 2) are non-coprime with LCM(12, 2) = 12. Now, nums = [**12**,7,6,2].
+
+- (6, 2) are non-coprime with LCM(6, 2) = 6. Now, nums = [12,7,**6**].
+
+There are no more adjacent non-coprime numbers in nums.
+
+Thus, the final modified array is [12,7,6].
+
+Note that there are other ways to obtain the same resultant array.
+
+**Example 2:**
+
+**Input:** nums = [2,2,1,1,3,3,3]
+
+**Output:** [2,1,1,3]
+
+**Explanation:**
+
+- (3, 3) are non-coprime with LCM(3, 3) = 3. Now, nums = [2,2,1,1,**3**,3].
+
+- (3, 3) are non-coprime with LCM(3, 3) = 3. Now, nums = [2,2,1,1,**3**].
+
+- (2, 2) are non-coprime with LCM(2, 2) = 2. Now, nums = [**2**,1,1,3].
+
+There are no more adjacent non-coprime numbers in nums.
+
+Thus, the final modified array is [2,1,1,3].
+
+Note that there are other ways to obtain the same resultant array.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* 1 <= nums[i] <= 105
+* The test cases are generated such that the values in the final array are **less than or equal** to 108.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun replaceNonCoprimes(nums: IntArray): List {
+ val res = ArrayList()
+ var i = 1
+ res.add(nums[0])
+ while (i < nums.size) {
+ val first = res[res.size - 1]
+ val second = nums[i]
+ val gcd = gcd(first, second)
+ if (gcd > 1) {
+ val lcm = first.toLong() * second.toLong() / gcd
+ if (res.isNotEmpty()) {
+ res.removeAt(res.size - 1)
+ }
+ res.add(lcm.toInt())
+ recursivelyCheck(res)
+ } else {
+ res.add(second)
+ }
+ i++
+ }
+ return res
+ }
+
+ private fun gcd(a: Int, b: Int): Int {
+ if (a > b) {
+ return gcd(b, a)
+ }
+ return if (b % a == 0) {
+ a
+ } else gcd(b % a, a)
+ }
+
+ private fun recursivelyCheck(list: ArrayList) {
+ if (list.size < 2) {
+ return
+ }
+ val a = list.removeAt(list.size - 1)
+ val b = list.removeAt(list.size - 1)
+ val gcd = gcd(a, b)
+ if (gcd > 1) {
+ val lcm = a.toLong() * b.toLong() / gcd
+ list.add(lcm.toInt())
+ recursivelyCheck(list)
+ } else {
+ list.add(b)
+ list.add(a)
+ }
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2101_2200/s2200_find_all_k_distant_indices_in_an_array/readme.md b/src/main/kotlin/g2101_2200/s2200_find_all_k_distant_indices_in_an_array/readme.md
new file mode 100644
index 00000000..53a826b3
--- /dev/null
+++ b/src/main/kotlin/g2101_2200/s2200_find_all_k_distant_indices_in_an_array/readme.md
@@ -0,0 +1,73 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2200\. Find All K-Distant Indices in an Array
+
+Easy
+
+You are given a **0-indexed** integer array `nums` and two integers `key` and `k`. A **k-distant index** is an index `i` of `nums` for which there exists at least one index `j` such that `|i - j| <= k` and `nums[j] == key`.
+
+Return _a list of all k-distant indices sorted in **increasing order**_.
+
+**Example 1:**
+
+**Input:** nums = [3,4,9,1,3,9,5], key = 9, k = 1
+
+**Output:** [1,2,3,4,5,6]
+
+**Explanation:** Here, nums[2] == key and nums[5] == key.
+
+- For index 0, \|0 - 2\| > k and \|0 - 5\| > k, so there is no j where \|0 - j\| <= k and nums[j] == key. Thus, 0 is not a k-distant index.
+
+- For index 1, \|1 - 2\| <= k and nums[2] == key, so 1 is a k-distant index.
+
+- For index 2, \|2 - 2\| <= k and nums[2] == key, so 2 is a k-distant index.
+
+- For index 3, \|3 - 2\| <= k and nums[2] == key, so 3 is a k-distant index.
+
+- For index 4, \|4 - 5\| <= k and nums[5] == key, so 4 is a k-distant index.
+
+- For index 5, \|5 - 5\| <= k and nums[5] == key, so 5 is a k-distant index.
+
+- For index 6, \|6 - 5\| <= k and nums[5] == key, so 6 is a k-distant index.
+
+Thus, we return [1,2,3,4,5,6] which is sorted in increasing order.
+
+**Example 2:**
+
+**Input:** nums = [2,2,2,2,2], key = 2, k = 2
+
+**Output:** [0,1,2,3,4]
+
+**Explanation:** For all indices i in nums, there exists some index j such that \|i - j\| <= k and nums[j] == key, so every index is a k-distant index.
+
+Hence, we return [0,1,2,3,4].
+
+**Constraints:**
+
+* `1 <= nums.length <= 1000`
+* `1 <= nums[i] <= 1000`
+* `key` is an integer from the array `nums`.
+* `1 <= k <= nums.length`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun findKDistantIndices(nums: IntArray, key: Int, k: Int): List {
+ val ans: MutableList = ArrayList()
+ var start = 0
+ val n = nums.size
+ for (i in 0 until n) {
+ if (nums[i] == key) {
+ start = Math.max(i - k, start)
+ val end = Math.min(i + k, n - 1)
+ while (start <= end) {
+ ans.add(start++)
+ }
+ }
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2201_count_artifacts_that_can_be_extracted/readme.md b/src/main/kotlin/g2201_2300/s2201_count_artifacts_that_can_be_extracted/readme.md
new file mode 100644
index 00000000..1cd998e5
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2201_count_artifacts_that_can_be_extracted/readme.md
@@ -0,0 +1,95 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2201\. Count Artifacts That Can Be Extracted
+
+Medium
+
+There is an `n x n` **0-indexed** grid with some artifacts buried in it. You are given the integer `n` and a **0-indexed** 2D integer array `artifacts` describing the positions of the rectangular artifacts where artifacts[i] = [r1i, c1i, r2i, c2i] denotes that the ith artifact is buried in the subgrid where:
+
+* (r1i, c1i) is the coordinate of the **top-left** cell of the ith artifact and
+* (r2i, c2i) is the coordinate of the **bottom-right** cell of the ith artifact.
+
+You will excavate some cells of the grid and remove all the mud from them. If the cell has a part of an artifact buried underneath, it will be uncovered. If all the parts of an artifact are uncovered, you can extract it.
+
+Given a **0-indexed** 2D integer array `dig` where dig[i] = [ri, ci] indicates that you will excavate the cell (ri, ci), return _the number of artifacts that you can extract_.
+
+The test cases are generated such that:
+
+* No two artifacts overlap.
+* Each artifact only covers at most `4` cells.
+* The entries of `dig` are unique.
+
+**Example 1:**
+
+
+
+**Input:** n = 2, artifacts = \[\[0,0,0,0],[0,1,1,1]], dig = \[\[0,0],[0,1]]
+
+**Output:** 1
+
+**Explanation:** The different colors represent different artifacts. Excavated cells are labeled with a 'D' in the grid. There is 1 artifact that can be extracted, namely the red artifact. The blue artifact has one part in cell (1,1) which remains uncovered, so we cannot extract it. Thus, we return 1.
+
+**Example 2:**
+
+
+
+**Input:** n = 2, artifacts = \[\[0,0,0,0],[0,1,1,1]], dig = \[\[0,0],[0,1],[1,1]]
+
+**Output:** 2
+
+**Explanation:** Both the red and blue artifacts have all parts uncovered (labeled with a 'D') and can be extracted, so we return 2.
+
+**Constraints:**
+
+* `1 <= n <= 1000`
+* 1 <= artifacts.length, dig.length <= min(n2, 105)
+* `artifacts[i].length == 4`
+* `dig[i].length == 2`
+* 0 <= r1i, c1i, r2i, c2i, ri, ci <= n - 1
+* r1i <= r2i
+* c1i <= c2i
+* No two artifacts will overlap.
+* The number of cells covered by an artifact is **at most** `4`.
+* The entries of `dig` are unique.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun digArtifacts(n: Int, artifacts: Array, dig: Array): Int {
+ val ar = Array(n) { IntArray(n) }
+ for (ints in dig) {
+ ar[ints[0]][ints[1]] = 1
+ }
+ var ans = 0
+ for (artifact in artifacts) {
+ val x1 = artifact[0]
+ val y1 = artifact[1]
+ val x2 = artifact[2]
+ val y2 = artifact[3]
+ var flag = 0
+ var a = x1
+ var b = y1
+ while (a <= x2) {
+ b = y1
+ while (b <= y2) {
+ if (ar[a][b] != 1) {
+ flag = 1
+ break
+ }
+ b++
+ }
+ if (flag == 1) {
+ break
+ }
+ a++
+ }
+ if (a == x2 + 1 && b == y2 + 1) {
+ ans++
+ }
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2202_maximize_the_topmost_element_after_k_moves/readme.md b/src/main/kotlin/g2201_2300/s2202_maximize_the_topmost_element_after_k_moves/readme.md
new file mode 100644
index 00000000..3db6f5a0
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2202_maximize_the_topmost_element_after_k_moves/readme.md
@@ -0,0 +1,78 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2202\. Maximize the Topmost Element After K Moves
+
+Medium
+
+You are given a **0-indexed** integer array `nums` representing the contents of a **pile**, where `nums[0]` is the topmost element of the pile.
+
+In one move, you can perform **either** of the following:
+
+* If the pile is not empty, **remove** the topmost element of the pile.
+* If there are one or more removed elements, **add** any one of them back onto the pile. This element becomes the new topmost element.
+
+You are also given an integer `k`, which denotes the total number of moves to be made.
+
+Return _the **maximum value** of the topmost element of the pile possible after **exactly**_ `k` _moves_. In case it is not possible to obtain a non-empty pile after `k` moves, return `-1`.
+
+**Example 1:**
+
+**Input:** nums = [5,2,2,4,0,6], k = 4
+
+**Output:** 5
+
+**Explanation:**
+
+One of the ways we can end with 5 at the top of the pile after 4 moves is as follows:
+
+- Step 1: Remove the topmost element = 5. The pile becomes [2,2,4,0,6].
+
+- Step 2: Remove the topmost element = 2. The pile becomes [2,4,0,6].
+
+- Step 3: Remove the topmost element = 2. The pile becomes [4,0,6].
+
+- Step 4: Add 5 back onto the pile. The pile becomes [5,4,0,6].
+
+Note that this is not the only way to end with 5 at the top of the pile. It can be shown that 5 is the largest answer possible after 4 moves.
+
+**Example 2:**
+
+**Input:** nums = [2], k = 1
+
+**Output:** -1
+
+**Explanation:**
+
+In the first move, our only option is to pop the topmost element of the pile.
+
+Since it is not possible to obtain a non-empty pile after one move, we return -1.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* 0 <= nums[i], k <= 109
+
+## Solution
+
+```kotlin
+class Solution {
+ fun maximumTop(nums: IntArray, k: Int): Int {
+ var max = -1
+ val maxTravers = Math.min(k + 1, nums.size)
+ if (nums.size == 1) {
+ return if (k % 2 == 0) {
+ nums[0]
+ } else {
+ max
+ }
+ }
+ for (i in 0 until maxTravers) {
+ if (nums[i] > max && i != k - 1) {
+ max = nums[i]
+ }
+ }
+ return max
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2203_minimum_weighted_subgraph_with_the_required_paths/readme.md b/src/main/kotlin/g2201_2300/s2203_minimum_weighted_subgraph_with_the_required_paths/readme.md
new file mode 100644
index 00000000..597a6723
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2203_minimum_weighted_subgraph_with_the_required_paths/readme.md
@@ -0,0 +1,99 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2203\. Minimum Weighted Subgraph With the Required Paths
+
+Hard
+
+You are given an integer `n` denoting the number of nodes of a **weighted directed** graph. The nodes are numbered from `0` to `n - 1`.
+
+You are also given a 2D integer array `edges` where edges[i] = [fromi, toi, weighti] denotes that there exists a **directed** edge from fromi to toi with weight weighti.
+
+Lastly, you are given three **distinct** integers `src1`, `src2`, and `dest` denoting three distinct nodes of the graph.
+
+Return _the **minimum weight** of a subgraph of the graph such that it is **possible** to reach_ `dest` _from both_ `src1` _and_ `src2` _via a set of edges of this subgraph_. In case such a subgraph does not exist, return `-1`.
+
+A **subgraph** is a graph whose vertices and edges are subsets of the original graph. The **weight** of a subgraph is the sum of weights of its constituent edges.
+
+**Example 1:**
+
+
+
+**Input:** n = 6, edges = \[\[0,2,2],[0,5,6],[1,0,3],[1,4,5],[2,1,1],[2,3,3],[2,3,4],[3,4,2],[4,5,1]], src1 = 0, src2 = 1, dest = 5
+
+**Output:** 9
+
+**Explanation:** The above figure represents the input graph. The blue edges represent one of the subgraphs that yield the optimal answer. Note that the subgraph [[1,0,3],[0,5,6]] also yields the optimal answer. It is not possible to get a subgraph with less weight satisfying all the constraints.
+
+**Example 2:**
+
+
+
+**Input:** n = 3, edges = \[\[0,1,1],[2,1,1]], src1 = 0, src2 = 1, dest = 2
+
+**Output:** -1
+
+**Explanation:** The above figure represents the input graph. It can be seen that there does not exist any path from node 1 to node 2, hence there are no subgraphs satisfying all the constraints.
+
+**Constraints:**
+
+* 3 <= n <= 105
+* 0 <= edges.length <= 105
+* `edges[i].length == 3`
+* 0 <= fromi, toi, src1, src2, dest <= n - 1
+* fromi != toi
+* `src1`, `src2`, and `dest` are pairwise distinct.
+* 1 <= weight[i] <= 105
+
+## Solution
+
+```kotlin
+import java.util.PriorityQueue
+import java.util.Queue
+
+class Solution {
+ fun minimumWeight(n: Int, edges: Array, src1: Int, src2: Int, dest: Int): Long {
+ val graph: Array?> = arrayOfNulls(n)
+ val weight = Array(3) { LongArray(n) }
+ for (i in 0 until n) {
+ for (j in 0..2) {
+ weight[j][i] = Long.MAX_VALUE
+ }
+ graph[i] = ArrayList()
+ }
+ for (e in edges) {
+ graph[e[0]]?.add(intArrayOf(e[1], e[2]))
+ }
+ val queue: Queue = PriorityQueue({ node1: Node, node2: Node -> node1.weight.compareTo(node2.weight) })
+ queue.offer(Node(0, src1, 0))
+ weight[0][src1] = 0
+ queue.offer(Node(1, src2, 0))
+ weight[1][src2] = 0
+ while (queue.isNotEmpty()) {
+ val curr = queue.poll()
+ if (curr.vertex == dest && curr.index == 2) {
+ return curr.weight
+ }
+ for (next in graph[curr.vertex]!!) {
+ if (curr.index == 2 && weight[curr.index][next[0]] > curr.weight + next[1]) {
+ weight[curr.index][next[0]] = curr.weight + next[1]
+ queue.offer(Node(curr.index, next[0], weight[curr.index][next[0]]))
+ } else if (weight[curr.index][next[0]] > curr.weight + next[1]) {
+ weight[curr.index][next[0]] = curr.weight + next[1]
+ queue.offer(Node(curr.index, next[0], weight[curr.index][next[0]]))
+ if (weight[curr.index xor 1][next[0]] != Long.MAX_VALUE &&
+ weight[curr.index][next[0]] + weight[curr.index xor 1][next[0]]
+ < weight[2][next[0]]
+ ) {
+ weight[2][next[0]] = weight[curr.index][next[0]] + weight[curr.index xor 1][next[0]]
+ queue.offer(Node(2, next[0], weight[2][next[0]]))
+ }
+ }
+ }
+ }
+ return -1
+ }
+
+ private class Node(var index: Int, var vertex: Int, var weight: Long)
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2206_divide_array_into_equal_pairs/readme.md b/src/main/kotlin/g2201_2300/s2206_divide_array_into_equal_pairs/readme.md
new file mode 100644
index 00000000..f5bdba3e
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2206_divide_array_into_equal_pairs/readme.md
@@ -0,0 +1,62 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2206\. Divide Array Into Equal Pairs
+
+Easy
+
+You are given an integer array `nums` consisting of `2 * n` integers.
+
+You need to divide `nums` into `n` pairs such that:
+
+* Each element belongs to **exactly one** pair.
+* The elements present in a pair are **equal**.
+
+Return `true` _if nums can be divided into_ `n` _pairs, otherwise return_ `false`.
+
+**Example 1:**
+
+**Input:** nums = [3,2,3,2,2,2]
+
+**Output:** true
+
+**Explanation:**
+
+There are 6 elements in nums, so they should be divided into 6 / 2 = 3 pairs.
+
+If nums is divided into the pairs (2, 2), (3, 3), and (2, 2), it will satisfy all the conditions.
+
+**Example 2:**
+
+**Input:** nums = [1,2,3,4]
+
+**Output:** false
+
+**Explanation:**
+
+There is no way to divide nums into 4 / 2 = 2 pairs such that the pairs satisfy every condition.
+
+**Constraints:**
+
+* `nums.length == 2 * n`
+* `1 <= n <= 500`
+* `1 <= nums[i] <= 500`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun divideArray(nums: IntArray): Boolean {
+ val freq = IntArray(501)
+ for (num in nums) {
+ ++freq[num]
+ }
+ for (f in freq) {
+ if (f % 2 != 0) {
+ return false
+ }
+ }
+ return true
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2207_maximize_number_of_subsequences_in_a_string/readme.md b/src/main/kotlin/g2201_2300/s2207_maximize_number_of_subsequences_in_a_string/readme.md
new file mode 100644
index 00000000..efba5ca1
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2207_maximize_number_of_subsequences_in_a_string/readme.md
@@ -0,0 +1,78 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2207\. Maximize Number of Subsequences in a String
+
+Medium
+
+You are given a **0-indexed** string `text` and another **0-indexed** string `pattern` of length `2`, both of which consist of only lowercase English letters.
+
+You can add **either** `pattern[0]` **or** `pattern[1]` anywhere in `text` **exactly once**. Note that the character can be added even at the beginning or at the end of `text`.
+
+Return _the **maximum** number of times_ `pattern` _can occur as a **subsequence** of the modified_ `text`.
+
+A **subsequence** is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.
+
+**Example 1:**
+
+**Input:** text = "abdcdbc", pattern = "ac"
+
+**Output:** 4
+
+**Explanation:**
+
+If we add pattern[0] = 'a' in between text[1] and text[2], we get "ab**a**dcdbc". Now, the number of times "ac" occurs as a subsequence is 4.
+
+Some other strings which have 4 subsequences "ac" after adding a character to text are "**a**abdcdbc" and "abd**a**cdbc".
+
+However, strings such as "abdc**a**dbc", "abd**c**cdbc", and "abdcdbc**c**", although obtainable, have only 3 subsequences "ac" and are thus suboptimal.
+
+It can be shown that it is not possible to get more than 4 subsequences "ac" by adding only one character.
+
+**Example 2:**
+
+**Input:** text = "aabb", pattern = "ab"
+
+**Output:** 6
+
+**Explanation:**
+
+Some of the strings which can be obtained from text and have 6 subsequences "ab" are "**a**aabb", "aa**a**bb", and "aab**b**b".
+
+**Constraints:**
+
+* 1 <= text.length <= 105
+* `pattern.length == 2`
+* `text` and `pattern` consist only of lowercase English letters.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun maximumSubsequenceCount(text: String, pattern: String): Long {
+ val first = pattern[0]
+ val second = pattern[1]
+ if (first == second) {
+ var res: Long = 0
+ for (c in text.toCharArray()) {
+ if (c == first) {
+ res++
+ }
+ }
+ return res * (res + 1) / 2
+ }
+ var res: Long = 0
+ var firstCount = 0
+ var secondCount = 0
+ for (c in text.toCharArray()) {
+ if (c == first) {
+ firstCount++
+ } else if (c == second) {
+ secondCount++
+ res += firstCount.toLong()
+ }
+ }
+ return Math.max(res + secondCount, res + firstCount)
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2208_minimum_operations_to_halve_array_sum/readme.md b/src/main/kotlin/g2201_2300/s2208_minimum_operations_to_halve_array_sum/readme.md
new file mode 100644
index 00000000..37356c68
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2208_minimum_operations_to_halve_array_sum/readme.md
@@ -0,0 +1,91 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2208\. Minimum Operations to Halve Array Sum
+
+Medium
+
+You are given an array `nums` of positive integers. In one operation, you can choose **any** number from `nums` and reduce it to **exactly** half the number. (Note that you may choose this reduced number in future operations.)
+
+Return _the **minimum** number of operations to reduce the sum of_ `nums` _by **at least** half._
+
+**Example 1:**
+
+**Input:** nums = [5,19,8,1]
+
+**Output:** 3
+
+**Explanation:** The initial sum of nums is equal to 5 + 19 + 8 + 1 = 33.
+
+The following is one of the ways to reduce the sum by at least half:
+
+Pick the number 19 and reduce it to 9.5.
+
+Pick the number 9.5 and reduce it to 4.75.
+
+Pick the number 8 and reduce it to 4.
+
+The final array is [5, 4.75, 4, 1] with a total sum of 5 + 4.75 + 4 + 1 = 14.75.
+
+The sum of nums has been reduced by 33 - 14.75 = 18.25, which is at least half of the initial sum, 18.25 >= 33/2 = 16.5.
+
+Overall, 3 operations were used so we return 3.
+
+It can be shown that we cannot reduce the sum by at least half in less than 3 operations.
+
+**Example 2:**
+
+**Input:** nums = [3,8,20]
+
+**Output:** 3
+
+**Explanation:** The initial sum of nums is equal to 3 + 8 + 20 = 31.
+
+The following is one of the ways to reduce the sum by at least half:
+
+Pick the number 20 and reduce it to 10.
+
+Pick the number 10 and reduce it to 5.
+
+Pick the number 3 and reduce it to 1.5.
+
+The final array is [1.5, 8, 5] with a total sum of 1.5 + 8 + 5 = 14.5.
+
+The sum of nums has been reduced by 31 - 14.5 = 16.5, which is at least half of the initial sum, 16.5 >= 31/2 = 16.5.
+
+Overall, 3 operations were used so we return 3.
+
+It can be shown that we cannot reduce the sum by at least half in less than 3 operations.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* 1 <= nums[i] <= 107
+
+## Solution
+
+```kotlin
+import java.util.Collections
+import java.util.PriorityQueue
+
+class Solution {
+ fun halveArray(nums: IntArray): Int {
+ val queue = PriorityQueue(nums.size, Collections.reverseOrder())
+ var sum = 0.0
+ var count = 0
+ for (num in nums) {
+ queue.add(num.toDouble())
+ sum += num
+ }
+ var hsum = sum
+ while (hsum > sum / 2) {
+ var maxElement = queue.poll()
+ maxElement /= 2
+ count++
+ hsum -= maxElement
+ queue.add(maxElement)
+ }
+ return count
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2209_minimum_white_tiles_after_covering_with_carpets/readme.md b/src/main/kotlin/g2201_2300/s2209_minimum_white_tiles_after_covering_with_carpets/readme.md
new file mode 100644
index 00000000..0da6b876
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2209_minimum_white_tiles_after_covering_with_carpets/readme.md
@@ -0,0 +1,86 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2209\. Minimum White Tiles After Covering With Carpets
+
+Hard
+
+You are given a **0-indexed binary** string `floor`, which represents the colors of tiles on a floor:
+
+* `floor[i] = '0'` denotes that the ith tile of the floor is colored **black**.
+* On the other hand, `floor[i] = '1'` denotes that the ith tile of the floor is colored **white**.
+
+You are also given `numCarpets` and `carpetLen`. You have `numCarpets` **black** carpets, each of length `carpetLen` tiles. Cover the tiles with the given carpets such that the number of **white** tiles still visible is **minimum**. Carpets may overlap one another.
+
+Return _the **minimum** number of white tiles still visible._
+
+**Example 1:**
+
+
+
+**Input:** floor = "10110101", numCarpets = 2, carpetLen = 2
+
+**Output:** 2
+
+**Explanation:**
+
+The figure above shows one way of covering the tiles with the carpets such that only 2 white tiles are visible.
+
+No other way of covering the tiles with the carpets can leave less than 2 white tiles visible.
+
+**Example 2:**
+
+
+
+**Input:** floor = "11111", numCarpets = 2, carpetLen = 3
+
+**Output:** 0
+
+**Explanation:**
+
+The figure above shows one way of covering the tiles with the carpets such that no white tiles are visible.
+
+Note that the carpets are able to overlap one another.
+
+**Constraints:**
+
+* `1 <= carpetLen <= floor.length <= 1000`
+* `floor[i]` is either `'0'` or `'1'`.
+* `1 <= numCarpets <= 1000`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minimumWhiteTiles(floor: String, numCarpets: Int, carpetLen: Int): Int {
+ val len = floor.length
+ val dp = Array(numCarpets + 1) { IntArray(len + 1) }
+ val prefix = IntArray(len)
+ var tiles = 0
+ var total = 0
+ for (i in 0 until len) {
+ // calculate total no of Tiles within the Carpet Length Window
+ tiles += floor[i].code - '0'.code
+ // start excluding tiles which are not in the Range anymore of the Carpet Length given
+ if (i - carpetLen >= 0) {
+ tiles -= floor[i - carpetLen].code - '0'.code
+ }
+ // the total no of tiles covered within the Carpet Length range for current index
+ prefix[i] = tiles
+ total += floor[i].code - '0'.code
+ }
+ for (i in 1..numCarpets) {
+ for (j in 0 until len) {
+ // if we do not wish to cover current Tile
+ val doNot = dp[i][j]
+ // if we do wish to cover current tile
+ val doTake = dp[i - 1][Math.max(0, j - carpetLen + 1)] + prefix[j]
+ // we should go back the Carpet length & check for tiles not covered before j -
+ // carpet Length distance
+ dp[i][j + 1] = Math.max(doTake, doNot)
+ }
+ }
+ return total - dp[numCarpets][len]
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2210_count_hills_and_valleys_in_an_array/readme.md b/src/main/kotlin/g2201_2300/s2210_count_hills_and_valleys_in_an_array/readme.md
new file mode 100644
index 00000000..6914fe02
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2210_count_hills_and_valleys_in_an_array/readme.md
@@ -0,0 +1,73 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2210\. Count Hills and Valleys in an Array
+
+Easy
+
+You are given a **0-indexed** integer array `nums`. An index `i` is part of a **hill** in `nums` if the closest non-equal neighbors of `i` are smaller than `nums[i]`. Similarly, an index `i` is part of a **valley** in `nums` if the closest non-equal neighbors of `i` are larger than `nums[i]`. Adjacent indices `i` and `j` are part of the **same** hill or valley if `nums[i] == nums[j]`.
+
+Note that for an index to be part of a hill or valley, it must have a non-equal neighbor on **both** the left and right of the index.
+
+Return _the number of hills and valleys in_ `nums`.
+
+**Example 1:**
+
+**Input:** nums = [2,4,1,1,6,5]
+
+**Output:** 3
+
+**Explanation:**
+
+At index 0: There is no non-equal neighbor of 2 on the left, so index 0 is neither a hill nor a valley.
+
+At index 1: The closest non-equal neighbors of 4 are 2 and 1. Since 4 > 2 and 4 > 1, index 1 is a hill.
+
+At index 2: The closest non-equal neighbors of 1 are 4 and 6. Since 1 < 4 and 1 < 6, index 2 is a valley.
+
+At index 3: The closest non-equal neighbors of 1 are 4 and 6. Since 1 < 4 and 1 < 6, index 3 is a valley, but note that it is part of the same valley as index 2. At index 4: The closest non-equal neighbors of 6 are 1 and 5. Since 6 > 1 and 6 > 5, index 4 is a hill.
+
+At index 5: There is no non-equal neighbor of 5 on the right, so index 5 is neither a hill nor a valley. There are 3 hills and valleys so we return 3.
+
+**Example 2:**
+
+**Input:** nums = [6,6,5,5,4,1]
+
+**Output:** 0
+
+**Explanation:**
+
+At index 0: There is no non-equal neighbor of 6 on the left, so index 0 is neither a hill nor a valley.
+
+At index 1: There is no non-equal neighbor of 6 on the left, so index 1 is neither a hill nor a valley.
+
+At index 2: The closest non-equal neighbors of 5 are 6 and 4. Since 5 < 6 and 5 > 4, index 2 is neither a hill nor a valley.
+
+At index 3: The closest non-equal neighbors of 5 are 6 and 4. Since 5 < 6 and 5 > 4, index 3 is neither a hill nor a valley.
+
+At index 4: The closest non-equal neighbors of 4 are 5 and 1. Since 4 < 5 and 4 > 1, index 4 is neither a hill nor a valley.
+
+At index 5: There is no non-equal neighbor of 1 on the right, so index 5 is neither a hill nor a valley. There are 0 hills and valleys so we return 0.
+
+**Constraints:**
+
+* `3 <= nums.length <= 100`
+* `1 <= nums[i] <= 100`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun countHillValley(nums: IntArray): Int {
+ var left = nums[0]
+ var count = 0
+ for (i in 1 until nums.size - 1) {
+ if (left > nums[i] && nums[i + 1] > nums[i] || left < nums[i] && nums[i + 1] < nums[i]) {
+ count++
+ left = nums[i]
+ }
+ }
+ return count
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2211_count_collisions_on_a_road/readme.md b/src/main/kotlin/g2201_2300/s2211_count_collisions_on_a_road/readme.md
new file mode 100644
index 00000000..205efb21
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2211_count_collisions_on_a_road/readme.md
@@ -0,0 +1,101 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2211\. Count Collisions on a Road
+
+Medium
+
+There are `n` cars on an infinitely long road. The cars are numbered from `0` to `n - 1` from left to right and each car is present at a **unique** point.
+
+You are given a **0-indexed** string `directions` of length `n`. `directions[i]` can be either `'L'`, `'R'`, or `'S'` denoting whether the ith car is moving towards the **left**, towards the **right**, or **staying** at its current point respectively. Each moving car has the **same speed**.
+
+The number of collisions can be calculated as follows:
+
+* When two cars moving in **opposite** directions collide with each other, the number of collisions increases by `2`.
+* When a moving car collides with a stationary car, the number of collisions increases by `1`.
+
+After a collision, the cars involved can no longer move and will stay at the point where they collided. Other than that, cars cannot change their state or direction of motion.
+
+Return _the **total number of collisions** that will happen on the road_.
+
+**Example 1:**
+
+**Input:** directions = "RLRSLL"
+
+**Output:** 5
+
+**Explanation:** The collisions that will happen on the road are:
+
+- Cars 0 and 1 will collide with each other. Since they are moving in opposite directions, the number of collisions becomes 0 + 2 = 2.
+
+- Cars 2 and 3 will collide with each other. Since car 3 is stationary, the number of collisions becomes 2 + 1 = 3.
+
+- Cars 3 and 4 will collide with each other. Since car 3 is stationary, the number of collisions becomes 3 + 1 = 4.
+
+- Cars 4 and 5 will collide with each other. After car 4 collides with car 3, it will stay at the point of collision and get hit by car 5. The number of collisions becomes 4 + 1 = 5.
+
+Thus, the total number of collisions that will happen on the road is 5.
+
+**Example 2:**
+
+**Input:** directions = "LLRR"
+
+**Output:** 0
+
+**Explanation:** No cars will collide with each other. Thus, the total number of collisions that will happen on the road is 0.
+
+**Constraints:**
+
+* 1 <= directions.length <= 105
+* `directions[i]` is either `'L'`, `'R'`, or `'S'`.
+
+## Solution
+
+```kotlin
+import java.util.ArrayDeque
+import java.util.Deque
+
+class Solution {
+ fun countCollisions(directions: String?): Int {
+ if (directions == null || directions.length == 1) {
+ return 0
+ }
+ val stack: Deque = ArrayDeque()
+ val direction = directions.toCharArray()
+ var prevc = '0'
+ var collision = 0
+ for (i in direction.indices) {
+ if (direction[i] == 'R') {
+ stack.push(direction[i])
+ } else {
+ if (direction[i] == 'S' && prevc == 'R') {
+ if (stack.isNotEmpty()) {
+ stack.pop()
+ }
+ collision += 1
+ direction[i] = 'S'
+ while (stack.isNotEmpty()) {
+ collision++
+ stack.pop()
+ }
+ }
+ if (direction[i] == 'L' && prevc == 'R') {
+ stack.pop()
+ collision += 2
+ direction[i] = 'S'
+ while (stack.isNotEmpty()) {
+ collision++
+ stack.pop()
+ }
+ }
+ if (direction[i] == 'L' && prevc == 'S') {
+ collision++
+ direction[i] = 'S'
+ }
+ }
+ prevc = direction[i]
+ }
+ return collision
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2212_maximum_points_in_an_archery_competition/readme.md b/src/main/kotlin/g2201_2300/s2212_maximum_points_in_an_archery_competition/readme.md
new file mode 100644
index 00000000..92419240
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2212_maximum_points_in_an_archery_competition/readme.md
@@ -0,0 +1,81 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2212\. Maximum Points in an Archery Competition
+
+Medium
+
+Alice and Bob are opponents in an archery competition. The competition has set the following rules:
+
+1. Alice first shoots `numArrows` arrows and then Bob shoots `numArrows` arrows.
+2. The points are then calculated as follows:
+ 1. The target has integer scoring sections ranging from `0` to `11` **inclusive**.
+ 2. For **each** section of the target with score `k` (in between `0` to `11`), say Alice and Bob have shot ak and bk arrows on that section respectively. If ak >= bk, then Alice takes `k` points. If ak < bk, then Bob takes `k` points.
+ 3. However, if ak == bk == 0, then **nobody** takes `k` points.
+
+* For example, if Alice and Bob both shot `2` arrows on the section with score `11`, then Alice takes `11` points. On the other hand, if Alice shot `0` arrows on the section with score `11` and Bob shot `2` arrows on that same section, then Bob takes `11` points.
+
+
+You are given the integer `numArrows` and an integer array `aliceArrows` of size `12`, which represents the number of arrows Alice shot on each scoring section from `0` to `11`. Now, Bob wants to **maximize** the total number of points he can obtain.
+
+Return _the array_ `bobArrows` _which represents the number of arrows Bob shot on **each** scoring section from_ `0` _to_ `11`. The sum of the values in `bobArrows` should equal `numArrows`.
+
+If there are multiple ways for Bob to earn the maximum total points, return **any** one of them.
+
+**Example 1:**
+
+
+
+**Input:** numArrows = 9, aliceArrows = [1,1,0,1,0,0,2,1,0,1,2,0]
+
+**Output:** [0,0,0,0,1,1,0,0,1,2,3,1]
+
+**Explanation:** The table above shows how the competition is scored. Bob earns a total point of 4 + 5 + 8 + 9 + 10 + 11 = 47. It can be shown that Bob cannot obtain a score higher than 47 points.
+
+**Example 2:**
+
+
+
+**Input:** numArrows = 3, aliceArrows = [0,0,1,0,0,0,0,0,0,0,0,2]
+
+**Output:** [0,0,0,0,0,0,0,0,1,1,1,0]
+
+**Explanation:** The table above shows how the competition is scored. Bob earns a total point of 8 + 9 + 10 = 27. It can be shown that Bob cannot obtain a score higher than 27 points.
+
+**Constraints:**
+
+* 1 <= numArrows <= 105
+* `aliceArrows.length == bobArrows.length == 12`
+* `0 <= aliceArrows[i], bobArrows[i] <= numArrows`
+* `sum(aliceArrows[i]) == numArrows`
+
+## Solution
+
+```kotlin
+class Solution {
+ private val ans = IntArray(12)
+ private val ans1 = IntArray(12)
+ private var max = 0
+ fun maximumBobPoints(numArrows: Int, aliceArrows: IntArray): IntArray {
+ solve(numArrows, aliceArrows, 11, 0)
+ return ans1
+ }
+
+ private fun solve(numArrows: Int, aliceArrows: IntArray, index: Int, sum: Int) {
+ if (numArrows <= 0 || index < 0) {
+ if (max < sum) {
+ max = sum
+ ans1[0] = Math.max(ans[0], ans[0] + numArrows)
+ System.arraycopy(ans, 1, ans1, 1, 11)
+ }
+ return
+ }
+ if (aliceArrows[index] + 1 <= numArrows) {
+ ans[index] = aliceArrows[index] + 1
+ solve(numArrows - (aliceArrows[index] + 1), aliceArrows, index - 1, sum + index)
+ ans[index] = 0
+ }
+ solve(numArrows, aliceArrows, index - 1, sum)
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2213_longest_substring_of_one_repeating_character/readme.md b/src/main/kotlin/g2201_2300/s2213_longest_substring_of_one_repeating_character/readme.md
new file mode 100644
index 00000000..11033f20
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2213_longest_substring_of_one_repeating_character/readme.md
@@ -0,0 +1,136 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2213\. Longest Substring of One Repeating Character
+
+Hard
+
+You are given a **0-indexed** string `s`. You are also given a **0-indexed** string `queryCharacters` of length `k` and a **0-indexed** array of integer **indices** `queryIndices` of length `k`, both of which are used to describe `k` queries.
+
+The ith query updates the character in `s` at index `queryIndices[i]` to the character `queryCharacters[i]`.
+
+Return _an array_ `lengths` _of length_ `k` _where_ `lengths[i]` _is the **length** of the **longest substring** of_ `s` _consisting of **only one repeating** character **after** the_ ith _query_ _is performed._
+
+**Example 1:**
+
+**Input:** s = "babacc", queryCharacters = "bcb", queryIndices = [1,3,3]
+
+**Output:** [3,3,4]
+
+**Explanation:** - 1st query updates s = "b**b**bacc". The longest substring consisting of one repeating character is "bbb" with length 3.
+
+- 2nd query updates s = "bbb**c**cc". The longest substring consisting of one repeating character can be "bbb" or "ccc" with length 3.
+
+- 3rd query updates s = "bbb**b**cc". The longest substring consisting of one repeating character is "bbbb" with length 4.
+
+Thus, we return [3,3,4].
+
+**Example 2:**
+
+**Input:** s = "abyzz", queryCharacters = "aa", queryIndices = [2,1]
+
+**Output:** [2,3]
+
+**Explanation:** - 1st query updates s = "ab**a**zz". The longest substring consisting of one repeating character is "zz" with length 2.
+
+- 2nd query updates s = "a**a**azz". The longest substring consisting of one repeating character is "aaa" with length 3.
+
+Thus, we return [2,3].
+
+**Constraints:**
+
+* 1 <= s.length <= 105
+* `s` consists of lowercase English letters.
+* `k == queryCharacters.length == queryIndices.length`
+* 1 <= k <= 105
+* `queryCharacters` consists of lowercase English letters.
+* `0 <= queryIndices[i] < s.length`
+
+## Solution
+
+```kotlin
+class Solution {
+ internal class TreeNode(var start: Int, var end: Int) {
+ var leftChar = 0.toChar()
+ var leftCharLen = 0
+ var rightChar = 0.toChar()
+ var rightCharLen = 0
+ var max = 0
+ var left: TreeNode? = null
+ var right: TreeNode? = null
+ }
+
+ fun longestRepeating(s: String, queryCharacters: String, queryIndices: IntArray): IntArray {
+ val sChar = s.toCharArray()
+ val qChar = queryCharacters.toCharArray()
+ val root = buildTree(sChar, 0, sChar.size - 1)
+ val result = IntArray(qChar.size)
+ for (i in qChar.indices) {
+ updateTree(root, queryIndices[i], qChar[i])
+ if (root != null) {
+ result[i] = root.max
+ }
+ }
+ return result
+ }
+
+ private fun buildTree(s: CharArray, from: Int, to: Int): TreeNode? {
+ if (from > to) {
+ return null
+ }
+ val root = TreeNode(from, to)
+ if (from == to) {
+ root.max = 1
+ root.leftChar = s[from]
+ root.rightChar = root.leftChar
+ root.rightCharLen = 1
+ root.leftCharLen = root.rightCharLen
+ return root
+ }
+ val middle = from + (to - from) / 2
+ root.left = buildTree(s, from, middle)
+ root.right = buildTree(s, middle + 1, to)
+ updateNode(root)
+ return root
+ }
+
+ private fun updateTree(root: TreeNode?, index: Int, c: Char) {
+ if (root == null || root.start > index || root.end < index) {
+ return
+ }
+ if (root.start == index && root.end == index) {
+ root.rightChar = c
+ root.leftChar = root.rightChar
+ return
+ }
+ updateTree(root.left, index, c)
+ updateTree(root.right, index, c)
+ updateNode(root)
+ }
+
+ private fun updateNode(root: TreeNode?) {
+ if (root == null) {
+ return
+ }
+ root.leftChar = root.left!!.leftChar
+ root.leftCharLen = root.left!!.leftCharLen
+ root.rightChar = root.right!!.rightChar
+ root.rightCharLen = root.right!!.rightCharLen
+ root.max = Math.max(root.left!!.max, root.right!!.max)
+ if (root.left!!.rightChar == root.right!!.leftChar) {
+ val len = root.left!!.rightCharLen + root.right!!.leftCharLen
+ if (root.left!!.leftChar == root.left!!.rightChar &&
+ root.left!!.leftCharLen == root.left!!.end - root.left!!.start + 1
+ ) {
+ root.leftCharLen = len
+ }
+ if (root.right!!.leftChar == root.right!!.rightChar &&
+ root.right!!.leftCharLen == root.right!!.end - root.right!!.start + 1
+ ) {
+ root.rightCharLen = len
+ }
+ root.max = Math.max(root.max, len)
+ }
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2215_find_the_difference_of_two_arrays/readme.md b/src/main/kotlin/g2201_2300/s2215_find_the_difference_of_two_arrays/readme.md
new file mode 100644
index 00000000..8bdab0a1
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2215_find_the_difference_of_two_arrays/readme.md
@@ -0,0 +1,72 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2215\. Find the Difference of Two Arrays
+
+Easy
+
+Given two **0-indexed** integer arrays `nums1` and `nums2`, return _a list_ `answer` _of size_ `2` _where:_
+
+* `answer[0]` _is a list of all **distinct** integers in_ `nums1` _which are **not** present in_ `nums2`_._
+* `answer[1]` _is a list of all **distinct** integers in_ `nums2` _which are **not** present in_ `nums1`.
+
+**Note** that the integers in the lists may be returned in **any** order.
+
+**Example 1:**
+
+**Input:** nums1 = [1,2,3], nums2 = [2,4,6]
+
+**Output:** [[1,3],[4,6]]
+
+**Explanation:**
+
+For nums1, nums1[1] = 2 is present at index 0 of nums2, whereas nums1[0] = 1 and nums1[2] = 3 are not present in nums2. Therefore, answer[0] = [1,3].
+
+For nums2, nums2[0] = 2 is present at index 1 of nums1, whereas nums2[1] = 4 and nums2[2] = 6 are not present in nums2. Therefore, answer[1] = [4,6].
+
+**Example 2:**
+
+**Input:** nums1 = [1,2,3,3], nums2 = [1,1,2,2]
+
+**Output:** [[3],[]]
+
+**Explanation:**
+
+For nums1, nums1[2] and nums1[3] are not present in nums2. Since nums1[2] == nums1[3], their value is only included once and answer[0] = [3].
+
+Every integer in nums2 is present in nums1. Therefore, answer[1] = [].
+
+**Constraints:**
+
+* `1 <= nums1.length, nums2.length <= 1000`
+* `-1000 <= nums1[i], nums2[i] <= 1000`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun findDifference(nums1: IntArray, nums2: IntArray): List> {
+ val set1 = createSet(nums1)
+ val set2 = createSet(nums2)
+ return listOf(getMissing(set1, set2), getMissing(set2, set1))
+ }
+
+ private fun createSet(array: IntArray): Set {
+ val set: MutableSet = HashSet()
+ for (x in array) {
+ set.add(x)
+ }
+ return set
+ }
+
+ private fun getMissing(first: Set, second: Set): List {
+ val list: MutableList = ArrayList()
+ for (x in first) {
+ if (!second.contains(x)) {
+ list.add(x)
+ }
+ }
+ return list
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2216_minimum_deletions_to_make_array_beautiful/readme.md b/src/main/kotlin/g2201_2300/s2216_minimum_deletions_to_make_array_beautiful/readme.md
new file mode 100644
index 00000000..659985c8
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2216_minimum_deletions_to_make_array_beautiful/readme.md
@@ -0,0 +1,63 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2216\. Minimum Deletions to Make Array Beautiful
+
+Medium
+
+You are given a **0-indexed** integer array `nums`. The array `nums` is **beautiful** if:
+
+* `nums.length` is even.
+* `nums[i] != nums[i + 1]` for all `i % 2 == 0`.
+
+Note that an empty array is considered beautiful.
+
+You can delete any number of elements from `nums`. When you delete an element, all the elements to the right of the deleted element will be **shifted one unit to the left** to fill the gap created and all the elements to the left of the deleted element will remain **unchanged**.
+
+Return _the **minimum** number of elements to delete from_ `nums` _to make it_ _beautiful._
+
+**Example 1:**
+
+**Input:** nums = [1,1,2,3,5]
+
+**Output:** 1
+
+**Explanation:** You can delete either `nums[0]` or `nums[1]` to make `nums` = [1,2,3,5] which is beautiful. It can be proven you need at least 1 deletion to make `nums` beautiful.
+
+**Example 2:**
+
+**Input:** nums = [1,1,2,2,3,3]
+
+**Output:** 2
+
+**Explanation:** You can delete `nums[0]` and `nums[5]` to make nums = [1,2,2,3] which is beautiful. It can be proven you need at least 2 deletions to make nums beautiful.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* 0 <= nums[i] <= 105
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minDeletion(nums: IntArray): Int {
+ var offset = 0
+ var res = 0
+ var i = 0
+ while (i < nums.size) {
+ var j = i
+ while (j < nums.size - 1 && nums[j + 1] == nums[j] && (j - offset) % 2 == 0) {
+ offset++
+ res++
+ j++
+ }
+ i = j + 2
+ }
+ if ((nums.size - offset) % 2 != 0) {
+ res++
+ }
+ return res
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2217_find_palindrome_with_fixed_length/readme.md b/src/main/kotlin/g2201_2300/s2217_find_palindrome_with_fixed_length/readme.md
new file mode 100644
index 00000000..4eb4359f
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2217_find_palindrome_with_fixed_length/readme.md
@@ -0,0 +1,72 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2217\. Find Palindrome With Fixed Length
+
+Medium
+
+Given an integer array `queries` and a **positive** integer `intLength`, return _an array_ `answer` _where_ `answer[i]` _is either the_ queries[i]th _smallest **positive palindrome** of length_ `intLength` _or_ `-1` _if no such palindrome exists_.
+
+A **palindrome** is a number that reads the same backwards and forwards. Palindromes cannot have leading zeros.
+
+**Example 1:**
+
+**Input:** queries = [1,2,3,4,5,90], intLength = 3
+
+**Output:** [101,111,121,131,141,999]
+
+**Explanation:**
+
+The first few palindromes of length 3 are:
+
+101, 111, 121, 131, 141, 151, 161, 171, 181, 191, 202, ...
+
+The 90th palindrome of length 3 is 999.
+
+**Example 2:**
+
+**Input:** queries = [2,4,6], intLength = 4
+
+**Output:** [1111,1331,1551]
+
+**Explanation:**
+
+The first six palindromes of length 4 are:
+
+1001, 1111, 1221, 1331, 1441, and 1551.
+
+**Constraints:**
+
+* 1 <= queries.length <= 5 * 104
+* 1 <= queries[i] <= 109
+* `1 <= intLength <= 15`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun kthPalindrome(queries: IntArray, intLength: Int): LongArray {
+ val minHalf = Math.pow(10.0, ((intLength - 1) / 2).toDouble()).toLong()
+ val maxIndex = Math.pow(10.0, ((intLength + 1) / 2).toDouble()).toLong() - minHalf
+ val isOdd = intLength % 2 == 1
+ val res = LongArray(queries.size)
+ for (i in res.indices) {
+ res[i] = if (queries[i] > maxIndex) -1 else helper(queries[i].toLong(), minHalf, isOdd)
+ }
+ return res
+ }
+
+ private fun helper(index: Long, minHalf: Long, isOdd: Boolean): Long {
+ var half = minHalf + index - 1
+ var res = half
+ if (isOdd) {
+ res /= 10
+ }
+ while (half != 0L) {
+ res = res * 10 + half % 10
+ half /= 10
+ }
+ return res
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2218_maximum_value_of_k_coins_from_piles/readme.md b/src/main/kotlin/g2201_2300/s2218_maximum_value_of_k_coins_from_piles/readme.md
new file mode 100644
index 00000000..145a1a3c
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2218_maximum_value_of_k_coins_from_piles/readme.md
@@ -0,0 +1,66 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2218\. Maximum Value of K Coins From Piles
+
+Hard
+
+There are `n` **piles** of coins on a table. Each pile consists of a **positive number** of coins of assorted denominations.
+
+In one move, you can choose any coin on **top** of any pile, remove it, and add it to your wallet.
+
+Given a list `piles`, where `piles[i]` is a list of integers denoting the composition of the ith pile from **top to bottom**, and a positive integer `k`, return _the **maximum total value** of coins you can have in your wallet if you choose **exactly**_ `k` _coins optimally_.
+
+**Example 1:**
+
+
+
+**Input:** piles = \[\[1,100,3],[7,8,9]], k = 2
+
+**Output:** 101
+
+**Explanation:** The above diagram shows the different ways we can choose k coins.
+
+The maximum total we can obtain is 101.
+
+**Example 2:**
+
+**Input:** piles = \[\[100],[100],[100],[100],[100],[100],[1,1,1,1,1,1,700]], k = 7
+
+**Output:** 706
+
+**Explanation:** The maximum total can be obtained if we choose all coins from the last pile.
+
+**Constraints:**
+
+* `n == piles.length`
+* `1 <= n <= 1000`
+* 1 <= piles[i][j] <= 105
+* `1 <= k <= sum(piles[i].length) <= 2000`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun maxValueOfCoins(piles: List>, k: Int): Int {
+ var dp = IntArray(k + 1)
+ for (pile in piles) {
+ val m = pile.size
+ val cum = IntArray(m + 1)
+ for (i in 0 until m) {
+ cum[i + 1] = cum[i] + pile[i]
+ }
+ val curdp = IntArray(k + 1)
+ for (i in 0..k) {
+ var j = 0
+ while (j <= m && i + j <= k) {
+ curdp[i + j] = Math.max(curdp[i + j], dp[i] + cum[j])
+ j++
+ }
+ }
+ dp = curdp
+ }
+ return dp[k]
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2220_minimum_bit_flips_to_convert_number/readme.md b/src/main/kotlin/g2201_2300/s2220_minimum_bit_flips_to_convert_number/readme.md
new file mode 100644
index 00000000..4e81f111
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2220_minimum_bit_flips_to_convert_number/readme.md
@@ -0,0 +1,78 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2220\. Minimum Bit Flips to Convert Number
+
+Easy
+
+A **bit flip** of a number `x` is choosing a bit in the binary representation of `x` and **flipping** it from either `0` to `1` or `1` to `0`.
+
+* For example, for `x = 7`, the binary representation is `111` and we may choose any bit (including any leading zeros not shown) and flip it. We can flip the first bit from the right to get `110`, flip the second bit from the right to get `101`, flip the fifth bit from the right (a leading zero) to get `10111`, etc.
+
+Given two integers `start` and `goal`, return _the **minimum** number of **bit flips** to convert_ `start` _to_ `goal`.
+
+**Example 1:**
+
+**Input:** start = 10, goal = 7
+
+**Output:** 3
+
+**Explanation:** The binary representation of 10 and 7 are 1010 and 0111 respectively. We can convert 10 to 7 in 3 steps:
+
+- Flip the first bit from the right: 1010 -> 1011.
+
+- Flip the third bit from the right: 1011 -> 1111\.
+
+- Flip the fourth bit from the right: 1111 -> 0111\.
+
+It can be shown we cannot convert 10 to 7 in less than 3 steps. Hence, we return 3.
+
+**Example 2:**
+
+**Input:** start = 3, goal = 4
+
+**Output:** 3
+
+**Explanation:** The binary representation of 3 and 4 are 011 and 100 respectively. We can convert 3 to 4 in 3 steps:
+
+- Flip the first bit from the right: 011 -> 010.
+
+- Flip the second bit from the right: 010 -> 000\.
+
+- Flip the third bit from the right: 000 -> 100\.
+
+It can be shown we cannot convert 3 to 4 in less than 3 steps. Hence, we return 3.
+
+**Constraints:**
+
+* 0 <= start, goal <= 109
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ private fun decToBinary(n: Int): Int {
+ var n = n
+ val binaryNum = IntArray(32)
+ var i = 0
+ while (n > 0) {
+ binaryNum[i] = n % 2
+ n = n / 2
+ i++
+ }
+ var answer = 0
+ for (j in i - 1 downTo 0) {
+ if (binaryNum[j] == 1) {
+ answer++
+ }
+ }
+ return answer
+ }
+
+ fun minBitFlips(start: Int, goal: Int): Int {
+ val answer = start xor goal
+ return decToBinary(answer)
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2221_find_triangular_sum_of_an_array/readme.md b/src/main/kotlin/g2201_2300/s2221_find_triangular_sum_of_an_array/readme.md
new file mode 100644
index 00000000..7668edec
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2221_find_triangular_sum_of_an_array/readme.md
@@ -0,0 +1,57 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2221\. Find Triangular Sum of an Array
+
+Medium
+
+You are given a **0-indexed** integer array `nums`, where `nums[i]` is a digit between `0` and `9` (**inclusive**).
+
+The **triangular sum** of `nums` is the value of the only element present in `nums` after the following process terminates:
+
+1. Let `nums` comprise of `n` elements. If `n == 1`, **end** the process. Otherwise, **create** a new **0-indexed** integer array `newNums` of length `n - 1`.
+2. For each index `i`, where `0 <= i < n - 1`, **assign** the value of `newNums[i]` as `(nums[i] + nums[i+1]) % 10`, where `%` denotes modulo operator.
+3. **Replace** the array `nums` with `newNums`.
+4. **Repeat** the entire process starting from step 1.
+
+Return _the triangular sum of_ `nums`.
+
+**Example 1:**
+
+
+
+**Input:** nums = [1,2,3,4,5]
+
+**Output:** 8
+
+**Explanation:** The above diagram depicts the process from which we obtain the triangular sum of the array.
+
+**Example 2:**
+
+**Input:** nums = [5]
+
+**Output:** 5
+
+**Explanation:** Since there is only one element in nums, the triangular sum is the value of that element itself.
+
+**Constraints:**
+
+* `1 <= nums.length <= 1000`
+* `0 <= nums[i] <= 9`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun triangularSum(nums: IntArray): Int {
+ var len = nums.size
+ while (len-- > 1) {
+ for (i in 0 until len) {
+ nums[i] += nums[i + 1]
+ nums[i] %= 10
+ }
+ }
+ return nums[0]
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2222_number_of_ways_to_select_buildings/readme.md b/src/main/kotlin/g2201_2300/s2222_number_of_ways_to_select_buildings/readme.md
new file mode 100644
index 00000000..a10e8c67
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2222_number_of_ways_to_select_buildings/readme.md
@@ -0,0 +1,79 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2222\. Number of Ways to Select Buildings
+
+Medium
+
+You are given a **0-indexed** binary string `s` which represents the types of buildings along a street where:
+
+* `s[i] = '0'` denotes that the ith building is an office and
+* `s[i] = '1'` denotes that the ith building is a restaurant.
+
+As a city official, you would like to **select** 3 buildings for random inspection. However, to ensure variety, **no two consecutive** buildings out of the **selected** buildings can be of the same type.
+
+* For example, given `s = "0**0**1**1**0**1**"`, we cannot select the 1st, 3rd, and 5th buildings as that would form `"0**11**"` which is **not** allowed due to having two consecutive buildings of the same type.
+
+Return _the **number of valid ways** to select 3 buildings._
+
+**Example 1:**
+
+**Input:** s = "001101"
+
+**Output:** 6
+
+**Explanation:** The following sets of indices selected are valid:
+
+- \[0,2,4] from "**0**0**1**1**0**1" forms "010"
+
+- \[0,3,4] from "**0**01**10**1" forms "010"
+
+- \[1,2,4] from "0**01**1**0**1" forms "010"
+
+- \[1,3,4] from "0**0**1**10**1" forms "010"
+
+- \[2,4,5] from "00**1**1**01**" forms "101"
+
+- \[3,4,5] from "001**101**" forms "101"
+
+No other selection is valid. Thus, there are 6 total ways.
+
+**Example 2:**
+
+**Input:** s = "11100"
+
+**Output:** 0
+
+**Explanation:** It can be shown that there are no valid selections.
+
+**Constraints:**
+
+* 3 <= s.length <= 105
+* `s[i]` is either `'0'` or `'1'`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun numberOfWays(s: String): Long {
+ var z: Long = 0
+ var o: Long = 0
+ var zo: Long = 0
+ var oz: Long = 0
+ var zoz: Long = 0
+ var ozo: Long = 0
+ for (c in s.toCharArray()) {
+ if (c == '0') {
+ zoz += zo
+ oz += o
+ z++
+ } else {
+ ozo += oz
+ zo += z
+ o++
+ }
+ }
+ return zoz + ozo
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2223_sum_of_scores_of_built_strings/readme.md b/src/main/kotlin/g2201_2300/s2223_sum_of_scores_of_built_strings/readme.md
new file mode 100644
index 00000000..448c48f9
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2223_sum_of_scores_of_built_strings/readme.md
@@ -0,0 +1,86 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2223\. Sum of Scores of Built Strings
+
+Hard
+
+You are **building** a string `s` of length `n` **one** character at a time, **prepending** each new character to the **front** of the string. The strings are labeled from `1` to `n`, where the string with length `i` is labeled si.
+
+* For example, for `s = "abaca"`, s1 == "a", s2 == "ca", s3 == "aca", etc.
+
+The **score** of si is the length of the **longest common prefix** between si and sn (Note that s == sn).
+
+Given the final string `s`, return _the **sum** of the **score** of every_ si.
+
+**Example 1:**
+
+**Input:** s = "babab"
+
+**Output:** 9
+
+**Explanation:** For s1 == "b", the longest common prefix is "b" which has a score of 1.
+
+For s2 == "ab", there is no common prefix so the score is 0.
+
+For s3 == "bab", the longest common prefix is "bab" which has a score of 3.
+
+For s4 == "abab", there is no common prefix so the score is 0.
+
+For s5 == "babab", the longest common prefix is "babab" which has a score of 5.
+
+The sum of the scores is 1 + 0 + 3 + 0 + 5 = 9, so we return 9.
+
+**Example 2:**
+
+**Input:** s = "azbazbzaz"
+
+**Output:** 14
+
+**Explanation:**
+
+For s2 == "az", the longest common prefix is "az" which has a score of 2.
+
+For s6 == "azbzaz", the longest common prefix is "azb" which has a score of 3.
+
+For s9 == "azbazbzaz", the longest common prefix is "azbazbzaz" which has a score of 9.
+
+For all other si, the score is 0.
+
+The sum of the scores is 2 + 3 + 9 = 14, so we return 14.
+
+**Constraints:**
+
+* 1 <= s.length <= 105
+* `s` consists of lowercase English letters.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun sumScores(s: String): Long {
+ val n = s.length
+ val ss = s.toCharArray()
+ val z = IntArray(n)
+ var l = 0
+ var r = 0
+ for (i in 1 until n) {
+ if (i <= r) {
+ z[i] = Math.min(z[i - l], r - i + 1)
+ }
+ while (i + z[i] < n && ss[z[i]] == ss[i + z[i]]) {
+ z[i]++
+ }
+ if (i + z[i] - 1 > r) {
+ l = i
+ r = i + z[i] - 1
+ }
+ }
+ var sum = n.toLong()
+ for (i in 0 until n) {
+ sum += z[i].toLong()
+ }
+ return sum
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2224_minimum_number_of_operations_to_convert_time/readme.md b/src/main/kotlin/g2201_2300/s2224_minimum_number_of_operations_to_convert_time/readme.md
new file mode 100644
index 00000000..e83c7ec3
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2224_minimum_number_of_operations_to_convert_time/readme.md
@@ -0,0 +1,77 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2224\. Minimum Number of Operations to Convert Time
+
+Easy
+
+You are given two strings `current` and `correct` representing two **24-hour times**.
+
+24-hour times are formatted as `"HH:MM"`, where `HH` is between `00` and `23`, and `MM` is between `00` and `59`. The earliest 24-hour time is `00:00`, and the latest is `23:59`.
+
+In one operation you can increase the time `current` by `1`, `5`, `15`, or `60` minutes. You can perform this operation **any** number of times.
+
+Return _the **minimum number of operations** needed to convert_ `current` _to_ `correct`.
+
+**Example 1:**
+
+**Input:** current = "02:30", correct = "04:35"
+
+**Output:** 3
+
+**Explanation:**
+
+We can convert current to correct in 3 operations as follows:
+
+- Add 60 minutes to current. current becomes "03:30".
+
+- Add 60 minutes to current. current becomes "04:30".
+
+- Add 5 minutes to current. current becomes "04:35".
+
+It can be proven that it is not possible to convert current to correct in fewer than 3 operations.
+
+**Example 2:**
+
+**Input:** current = "11:00", correct = "11:01"
+
+**Output:** 1
+
+**Explanation:** We only have to add one minute to current, so the minimum number of operations needed is 1.
+
+**Constraints:**
+
+* `current` and `correct` are in the format `"HH:MM"`
+* `current <= correct`
+
+## Solution
+
+```kotlin
+class Solution {
+ private val duration = intArrayOf(60, 15, 5, 1)
+ private var c = 0
+
+ fun convertTime(current: String, correct: String): Int {
+ val dmin = correct.substring(3).toInt() - current.substring(3).toInt()
+ val dhour = correct.substring(0, 2).toInt() - current.substring(0, 2).toInt()
+ val min = dhour * 60 + dmin
+ dfs(0, min)
+ return c
+ }
+
+ private fun dfs(i: Int, amount: Int) {
+ if (i == 4) {
+ return
+ }
+ if (amount == 0) {
+ return
+ }
+ if (amount - duration[i] >= 0) {
+ c++
+ dfs(i, amount - duration[i])
+ } else {
+ dfs(i + 1, amount)
+ }
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2225_find_players_with_zero_or_one_losses/readme.md b/src/main/kotlin/g2201_2300/s2225_find_players_with_zero_or_one_losses/readme.md
new file mode 100644
index 00000000..27fa2c02
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2225_find_players_with_zero_or_one_losses/readme.md
@@ -0,0 +1,76 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2225\. Find Players With Zero or One Losses
+
+Medium
+
+You are given an integer array `matches` where matches[i] = [winneri, loseri] indicates that the player winneri defeated player loseri in a match.
+
+Return _a list_ `answer` _of size_ `2` _where:_
+
+* `answer[0]` is a list of all players that have **not** lost any matches.
+* `answer[1]` is a list of all players that have lost exactly **one** match.
+
+The values in the two lists should be returned in **increasing** order.
+
+**Note:**
+
+* You should only consider the players that have played **at least one** match.
+* The testcases will be generated such that **no** two matches will have the **same** outcome.
+
+**Example 1:**
+
+**Input:** matches = \[\[1,3],[2,3],[3,6],[5,6],[5,7],[4,5],[4,8],[4,9],[10,4],[10,9]]
+
+**Output:** [[1,2,10],[4,5,7,8]]
+
+**Explanation:** Players 1, 2, and 10 have not lost any matches. Players 4, 5, 7, and 8 each have lost one match. Players 3, 6, and 9 each have lost two matches. Thus, answer[0] = [1,2,10] and answer[1] = [4,5,7,8].
+
+**Example 2:**
+
+**Input:** matches = \[\[2,3],[1,3],[5,4],[6,4]]
+
+**Output:** [[1,2,5,6],[]]
+
+**Explanation:** Players 1, 2, 5, and 6 have not lost any matches. Players 3 and 4 each have lost two matches. Thus, answer[0] = [1,2,5,6] and answer[1] = [].
+
+**Constraints:**
+
+* 1 <= matches.length <= 105
+* `matches[i].length == 2`
+* 1 <= winneri, loseri <= 105
+* winneri != loseri
+* All `matches[i]` are **unique**.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun findWinners(matches: Array): List> {
+ val map: MutableMap = HashMap()
+ val list1: MutableList = ArrayList()
+ val list2: MutableList = ArrayList()
+ val res: MutableList> = ArrayList()
+ for (match in matches) {
+ val winner = match[0]
+ val loser = match[1]
+ map.putIfAbsent(winner, 0)
+ map[loser] = map.getOrDefault(loser, 0) + 1
+ }
+ for ((key, value) in map) {
+ if (value == 0) {
+ list1.add(key)
+ }
+ if (value == 1) {
+ list2.add(key)
+ }
+ }
+ list1.sort()
+ list2.sort()
+ res.add(list1)
+ res.add(list2)
+ return res
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2226_maximum_candies_allocated_to_k_children/readme.md b/src/main/kotlin/g2201_2300/s2226_maximum_candies_allocated_to_k_children/readme.md
new file mode 100644
index 00000000..9c6baf8a
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2226_maximum_candies_allocated_to_k_children/readme.md
@@ -0,0 +1,78 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2226\. Maximum Candies Allocated to K Children
+
+Medium
+
+You are given a **0-indexed** integer array `candies`. Each element in the array denotes a pile of candies of size `candies[i]`. You can divide each pile into any number of **sub piles**, but you **cannot** merge two piles together.
+
+You are also given an integer `k`. You should allocate piles of candies to `k` children such that each child gets the **same** number of candies. Each child can take **at most one** pile of candies and some piles of candies may go unused.
+
+Return _the **maximum number of candies** each child can get._
+
+**Example 1:**
+
+**Input:** candies = [5,8,6], k = 3
+
+**Output:** 5
+
+**Explanation:** We can divide candies[1] into 2 piles of size 5 and 3, and candies[2] into 2 piles of size 5 and 1. We now have five piles of candies of sizes 5, 5, 3, 5, and 1. We can allocate the 3 piles of size 5 to 3 children. It can be proven that each child cannot receive more than 5 candies.
+
+**Example 2:**
+
+**Input:** candies = [2,5], k = 11
+
+**Output:** 0
+
+**Explanation:** There are 11 children but only 7 candies in total, so it is impossible to ensure each child receives at least one candy. Thus, each child gets no candy and the answer is 0.
+
+**Constraints:**
+
+* 1 <= candies.length <= 105
+* 1 <= candies[i] <= 107
+* 1 <= k <= 1012
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ fun maximumCandies(candies: IntArray, k: Long): Int {
+ var max = Int.MIN_VALUE
+ var sum: Long = 0
+ for (num in candies) {
+ max = Math.max(max, num)
+ sum += num.toLong()
+ }
+ if (sum < k) {
+ return 0
+ }
+ var left = 1
+ var right = max
+ while (left < right) {
+ val mid = left + (right - left) / 2
+ if (canBeDistributed(mid, candies, k)) {
+ left = if (!canBeDistributed(mid + 1, candies, k)) {
+ return mid
+ } else {
+ mid + 1
+ }
+ } else {
+ right = mid - 1
+ }
+ }
+ return left
+ }
+
+ private fun canBeDistributed(num: Int, candies: IntArray, k: Long): Boolean {
+ var k = k
+ var i = 0
+ while (i < candies.size && k > 0) {
+ k -= (candies[i] / num).toLong()
+ ++i
+ }
+ return k <= 0
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2227_encrypt_and_decrypt_strings/readme.md b/src/main/kotlin/g2201_2300/s2227_encrypt_and_decrypt_strings/readme.md
new file mode 100644
index 00000000..81ec4879
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2227_encrypt_and_decrypt_strings/readme.md
@@ -0,0 +1,97 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2227\. Encrypt and Decrypt Strings
+
+Hard
+
+You are given a character array `keys` containing **unique** characters and a string array `values` containing strings of length 2. You are also given another string array `dictionary` that contains all permitted original strings after decryption. You should implement a data structure that can encrypt or decrypt a **0-indexed** string.
+
+A string is **encrypted** with the following process:
+
+1. For each character `c` in the string, we find the index `i` satisfying `keys[i] == c` in `keys`.
+2. Replace `c` with `values[i]` in the string.
+
+Note that in case a character of the string is **not present** in `keys`, the encryption process cannot be carried out, and an empty string `""` is returned.
+
+A string is **decrypted** with the following process:
+
+1. For each substring `s` of length 2 occurring at an even index in the string, we find an `i` such that `values[i] == s`. If there are multiple valid `i`, we choose **any** one of them. This means a string could have multiple possible strings it can decrypt to.
+2. Replace `s` with `keys[i]` in the string.
+
+Implement the `Encrypter` class:
+
+* `Encrypter(char[] keys, String[] values, String[] dictionary)` Initializes the `Encrypter` class with `keys, values`, and `dictionary`.
+* `String encrypt(String word1)` Encrypts `word1` with the encryption process described above and returns the encrypted string.
+* `int decrypt(String word2)` Returns the number of possible strings `word2` could decrypt to that also appear in `dictionary`.
+
+**Example 1:**
+
+**Input** ["Encrypter", "encrypt", "decrypt"] [[['a', 'b', 'c', 'd'], ["ei", "zf", "ei", "am"], ["abcd", "acbd", "adbc", "badc", "dacb", "cadb", "cbda", "abad"]], ["abcd"], ["eizfeiam"]]
+
+**Output:** [null, "eizfeiam", 2]
+
+**Explanation:** Encrypter encrypter = new Encrypter([['a', 'b', 'c', 'd'], ["ei", "zf", "ei", "am"], ["abcd", "acbd", "adbc", "badc", "dacb", "cadb", "cbda", "abad"]);
+
+encrypter.encrypt("abcd"); // return "eizfeiam".
+ // 'a' maps to "ei", 'b' maps to "zf", 'c' maps to "ei", and 'd' maps to "am".
+
+encrypter.decrypt("eizfeiam"); // return 2.
+ // "ei" can map to 'a' or 'c', "zf" maps to 'b', and "am" maps to 'd'.
+ // Thus, the possible strings after decryption are "abad", "cbad", "abcd", and "cbcd".
+ // 2 of those strings, "abad" and "abcd", appear in dictionary, so the answer is 2.
+
+**Constraints:**
+
+* `1 <= keys.length == values.length <= 26`
+* `values[i].length == 2`
+* `1 <= dictionary.length <= 100`
+* `1 <= dictionary[i].length <= 100`
+* All `keys[i]` and `dictionary[i]` are **unique**.
+* `1 <= word1.length <= 2000`
+* `1 <= word2.length <= 200`
+* All `word1[i]` appear in `keys`.
+* `word2.length` is even.
+* `keys`, `values[i]`, `dictionary[i]`, `word1`, and `word2` only contain lowercase English letters.
+* At most `200` calls will be made to `encrypt` and `decrypt` **in total**.
+
+## Solution
+
+```kotlin
+class Encrypter(keys: CharArray, values: Array, dictionary: Array) {
+ private val eMap: MutableMap
+ private val dMap: MutableMap
+
+ init {
+ eMap = HashMap()
+ dMap = HashMap()
+ for (i in keys.indices) {
+ eMap[keys[i]] = values[i]
+ }
+ for (s in dictionary) {
+ val str = encrypt(s)
+ if (str != "" && str != "null") {
+ dMap[str] = dMap.getOrDefault(str, 0) + 1
+ }
+ }
+ }
+
+ fun encrypt(word1: String): String {
+ val sb = StringBuilder()
+ for (c in word1.toCharArray()) {
+ sb.append(eMap[c])
+ }
+ return sb.toString()
+ }
+
+ fun decrypt(word2: String): Int {
+ return dMap.getOrDefault(word2, 0)
+ }
+}
+/*
+ * Your Encrypter object will be instantiated and called as such:
+ * var obj = Encrypter(keys, values, dictionary)
+ * var param_1 = obj.encrypt(word1)
+ * var param_2 = obj.decrypt(word2)
+ */
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2231_largest_number_after_digit_swaps_by_parity/readme.md b/src/main/kotlin/g2201_2300/s2231_largest_number_after_digit_swaps_by_parity/readme.md
new file mode 100644
index 00000000..5b36bea3
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2231_largest_number_after_digit_swaps_by_parity/readme.md
@@ -0,0 +1,78 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2231\. Largest Number After Digit Swaps by Parity
+
+Easy
+
+You are given a positive integer `num`. You may swap any two digits of `num` that have the same **parity** (i.e. both odd digits or both even digits).
+
+Return _the **largest** possible value of_ `num` _after **any** number of swaps._
+
+**Example 1:**
+
+**Input:** num = 1234
+
+**Output:** 3412
+
+**Explanation:** Swap the digit 3 with the digit 1, this results in the number 3214.
+
+Swap the digit 2 with the digit 4, this results in the number 3412.
+
+Note that there may be other sequences of swaps but it can be shown that 3412 is the largest possible number.
+
+Also note that we may not swap the digit 4 with the digit 1 since they are of different parities.
+
+**Example 2:**
+
+**Input:** num = 65875
+
+**Output:** 87655
+
+**Explanation:** Swap the digit 8 with the digit 6, this results in the number 85675.
+
+Swap the first digit 5 with the digit 7, this results in the number 87655.
+
+Note that there may be other sequences of swaps but it can be shown that 87655 is the largest possible number.
+
+**Constraints:**
+
+* 1 <= num <= 109
+
+## Solution
+
+```kotlin
+class Solution {
+ fun largestInteger(num: Int): Int {
+ val str = num.toString().toCharArray()
+ var temp: Char
+ for (i in str.indices) {
+ temp = str[i]
+ var swapIndex = i
+ val even = str[i].code % 2 == 0
+ var max = Int.MIN_VALUE
+ if (even) {
+ for (j in i + 1 until str.size) {
+ if (str[j].code % 2 == 0 && str[j] > str[i] && str[j].code > max) {
+ max = str[j].code
+ temp = str[j]
+ swapIndex = j
+ }
+ }
+ } else {
+ for (j in i + 1 until str.size) {
+ if (str[j].code % 2 != 0 && str[j] > str[i] && str[j].code > max) {
+ max = str[j].code
+ temp = str[j]
+ swapIndex = j
+ }
+ }
+ }
+ val tempStr = str[i]
+ str[i] = temp
+ str[swapIndex] = tempStr
+ }
+ return Integer.valueOf(String(str))
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2232_minimize_result_by_adding_parentheses_to_expression/readme.md b/src/main/kotlin/g2201_2300/s2232_minimize_result_by_adding_parentheses_to_expression/readme.md
new file mode 100644
index 00000000..547e367a
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2232_minimize_result_by_adding_parentheses_to_expression/readme.md
@@ -0,0 +1,136 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2232\. Minimize Result by Adding Parentheses to Expression
+
+Medium
+
+You are given a **0-indexed** string `expression` of the form `"+"` where `` and `` represent positive integers.
+
+Add a pair of parentheses to `expression` such that after the addition of parentheses, `expression` is a **valid** mathematical expression and evaluates to the **smallest** possible value. The left parenthesis **must** be added to the left of `'+'` and the right parenthesis **must** be added to the right of `'+'`.
+
+Return `expression` _after adding a pair of parentheses such that_ `expression` _evaluates to the **smallest** possible value._ If there are multiple answers that yield the same result, return any of them.
+
+The input has been generated such that the original value of `expression`, and the value of `expression` after adding any pair of parentheses that meets the requirements fits within a signed 32-bit integer.
+
+**Example 1:**
+
+**Input:** expression = "247+38"
+
+**Output:** "2(47+38)"
+
+**Explanation:** The `expression` evaluates to 2 \* (47 + 38) = 2 \* 85 = 170.
+
+Note that "2(4)7+38" is invalid because the right parenthesis must be to the right of the `'+'`.
+
+It can be shown that 170 is the smallest possible value.
+
+**Example 2:**
+
+**Input:** expression = "12+34"
+
+**Output:** "1(2+3)4"
+
+**Explanation:** The expression evaluates to 1 \* (2 + 3) \* 4 = 1 \* 5 \* 4 = 20.
+
+**Example 3:**
+
+**Input:** expression = "999+999"
+
+**Output:** "(999+999)"
+
+**Explanation:** The `expression` evaluates to 999 + 999 = 1998.
+
+**Constraints:**
+
+* `3 <= expression.length <= 10`
+* `expression` consists of digits from `'1'` to `'9'` and `'+'`.
+* `expression` starts and ends with digits.
+* `expression` contains exactly one `'+'`.
+* The original value of `expression`, and the value of `expression` after adding any pair of parentheses that meets the requirements fits within a signed 32-bit integer.
+
+## Solution
+
+```kotlin
+class Solution {
+ // Variables for final solution, to avoid create combination Strings
+ private var currentLeft = 0
+ private var currentRight = 0
+ private var currentMin = Int.MAX_VALUE
+ fun minimizeResult(expression: String): String {
+ // Identify our starting point, to apply the expansion technique
+ val plusIndex = expression.indexOf("+")
+ // We start expanding from the first values to the left and right of the center (plus sign).
+ expand(plusIndex - 1, plusIndex + 1, expression)
+ // Build the final String. We add the parentheses to our expression in the already
+ // calculated indices, defined as global variables.
+ val stringBuilder = StringBuilder()
+ for (i in 0 until expression.length) {
+ if (i == currentLeft) {
+ stringBuilder.append('(')
+ }
+ stringBuilder.append(expression[i])
+ if (i == currentRight) {
+ stringBuilder.append(')')
+ }
+ }
+ return stringBuilder.toString()
+ }
+
+ // With this function, we calculate all possible combinations of parentheses from two pointers,
+ // left and right.
+ private fun expand(left: Int, right: Int, expression: String) {
+ if (left < 0 || right >= expression.length) {
+ return
+ }
+ // from zero to first parentheses
+ val a = evaluate(0, left, expression)
+ // from first parentheses to right parentheses (+1 means inclusive)
+ val b = evaluate(left, right + 1, expression)
+ // from right parentheses to the end of expression (+1 means inclusive)
+ val c = evaluate(right + 1, expression.length, expression)
+ // If the expression a * b * c is less than our current minimum
+ // this is our solution, we replace the variables with these new values.
+ if (a * b * c < currentMin) {
+ currentMin = a * b * c
+ currentLeft = left
+ currentRight = right
+ }
+ // Move parentheses left only
+ expand(left - 1, right, expression)
+ // Move parentheses right only
+ expand(left, right + 1, expression)
+ // Move parentheses left and right
+ expand(left - 1, right + 1, expression)
+ }
+
+ /* This function is responsible for calculating the expressions of each variable.
+
+ a = (0, left) // from the start of the expression to the first parentheses
+ b = (left, right) // between parentheses, include plus sign
+ c = (right, end of expression) // from the last parentheses to the end
+ */
+ private fun evaluate(left: Int, right: Int, expression: String): Int {
+ // This means that the parentheses are at the beginning or end of the expression and are
+ // equal to the range of the expression to be evaluated. Return 1 to avoid zero factors in
+ // equation (a * b * c).
+ if (left == right) {
+ return 1
+ }
+ var number = 0
+ for (i in left until right) {
+ // If we find a sign, we must add both parts, therefore, we convert the expression to (a
+ // + b).
+ // We return the variable (a) wich is (number) and add to what follows after the sign (i
+ // + 1).
+ // We call the same function to calculate the b value.
+ number = if (expression[i] == '+') {
+ return number + evaluate(i + 1, right, expression)
+ } else {
+ number * 10 + (expression[i].code - '0'.code)
+ }
+ }
+ return number
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2233_maximum_product_after_k_increments/readme.md b/src/main/kotlin/g2201_2300/s2233_maximum_product_after_k_increments/readme.md
new file mode 100644
index 00000000..7f70441b
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2233_maximum_product_after_k_increments/readme.md
@@ -0,0 +1,69 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2233\. Maximum Product After K Increments
+
+Medium
+
+You are given an array of non-negative integers `nums` and an integer `k`. In one operation, you may choose **any** element from `nums` and **increment** it by `1`.
+
+Return _the **maximum** **product** of_ `nums` _after **at most**_ `k` _operations._ Since the answer may be very large, return it **modulo** 109 + 7. Note that you should maximize the product before taking the modulo.
+
+**Example 1:**
+
+**Input:** nums = [0,4], k = 5
+
+**Output:** 20
+
+**Explanation:** Increment the first number 5 times.
+
+Now nums = [5, 4], with a product of 5 \* 4 = 20.
+
+It can be shown that 20 is maximum product possible, so we return 20.
+
+Note that there may be other ways to increment nums to have the maximum product.
+
+**Example 2:**
+
+**Input:** nums = [6,3,3,2], k = 2
+
+**Output:** 216
+
+**Explanation:** Increment the second number 1 time and increment the fourth number 1 time.
+
+Now nums = [6, 4, 3, 3], with a product of 6 \* 4 \* 3 \* 3 = 216.
+
+It can be shown that 216 is maximum product possible, so we return 216.
+
+Note that there may be other ways to increment nums to have the maximum product.
+
+**Constraints:**
+
+* 1 <= nums.length, k <= 105
+* 0 <= nums[i] <= 106
+
+## Solution
+
+```kotlin
+import java.util.PriorityQueue
+
+@Suppress("NAME_SHADOWING")
+class Solution {
+ fun maximumProduct(nums: IntArray, k: Int): Int {
+ var k = k
+ val pq = PriorityQueue()
+ for (num in nums) {
+ pq.add(num)
+ }
+ while (k-- > 0) {
+ pq.add(pq.poll() + 1)
+ }
+ var ans: Long = 1
+ val mod = 1000000007
+ while (pq.isNotEmpty()) {
+ ans = ans * pq.poll() % mod
+ }
+ return ans.toInt()
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2234_maximum_total_beauty_of_the_gardens/readme.md b/src/main/kotlin/g2201_2300/s2234_maximum_total_beauty_of_the_gardens/readme.md
new file mode 100644
index 00000000..9e5ccba3
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2234_maximum_total_beauty_of_the_gardens/readme.md
@@ -0,0 +1,120 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2234\. Maximum Total Beauty of the Gardens
+
+Hard
+
+Alice is a caretaker of `n` gardens and she wants to plant flowers to maximize the total beauty of all her gardens.
+
+You are given a **0-indexed** integer array `flowers` of size `n`, where `flowers[i]` is the number of flowers already planted in the ith garden. Flowers that are already planted **cannot** be removed. You are then given another integer `newFlowers`, which is the **maximum** number of flowers that Alice can additionally plant. You are also given the integers `target`, `full`, and `partial`.
+
+A garden is considered **complete** if it has **at least** `target` flowers. The **total beauty** of the gardens is then determined as the **sum** of the following:
+
+* The number of **complete** gardens multiplied by `full`.
+* The **minimum** number of flowers in any of the **incomplete** gardens multiplied by `partial`. If there are no incomplete gardens, then this value will be `0`.
+
+Return _the **maximum** total beauty that Alice can obtain after planting at most_ `newFlowers` _flowers._
+
+**Example 1:**
+
+**Input:** flowers = [1,3,1,1], newFlowers = 7, target = 6, full = 12, partial = 1
+
+**Output:** 14
+
+**Explanation:** Alice can plant
+
+- 2 flowers in the 0th garden
+
+- 3 flowers in the 1st garden
+
+- 1 flower in the 2nd garden
+
+- 1 flower in the 3rd garden
+
+The gardens will then be [3,6,2,2]. She planted a total of 2 + 3 + 1 + 1 = 7 flowers.
+
+There is 1 garden that is complete.
+
+The minimum number of flowers in the incomplete gardens is 2.
+
+Thus, the total beauty is 1 \* 12 + 2 \* 1 = 12 + 2 = 14.
+
+No other way of planting flowers can obtain a total beauty higher than 14.
+
+**Example 2:**
+
+**Input:** flowers = [2,4,5,3], newFlowers = 10, target = 5, full = 2, partial = 6
+
+**Output:** 30
+
+**Explanation:** Alice can plant
+
+- 3 flowers in the 0th garden
+
+- 0 flowers in the 1st garden
+
+- 0 flowers in the 2nd garden
+
+- 2 flowers in the 3rd garden
+
+The gardens will then be [5,4,5,5]. She planted a total of 3 + 0 + 0 + 2 = 5 flowers.
+
+There are 3 gardens that are complete.
+
+The minimum number of flowers in the incomplete gardens is 4.
+
+Thus, the total beauty is 3 \* 2 + 4 \* 6 = 6 + 24 = 30.
+
+No other way of planting flowers can obtain a total beauty higher than 30.
+
+Note that Alice could make all the gardens complete but in this case, she would obtain a lower total beauty.
+
+**Constraints:**
+
+* 1 <= flowers.length <= 105
+* 1 <= flowers[i], target <= 105
+* 1 <= newFlowers <= 1010
+* 1 <= full, partial <= 105
+
+## Solution
+
+```kotlin
+class Solution {
+ fun maximumBeauty(flowers: IntArray, newFlowers: Long, target: Int, full: Int, partial: Int): Long {
+ val n = flowers.size
+ val prefix = LongArray(n + 1)
+ flowers.sort()
+ for (i in 0 until n) {
+ prefix[i + 1] = prefix[i] + Math.min(flowers[i], target)
+ }
+ var res: Long = 0
+ var i = n - 1
+ for (c in 0..n) {
+ val remain = prefix[n] - prefix[n - c] + newFlowers - c * target.toLong()
+ var min: Long = 0
+ if (0 > remain) {
+ break
+ }
+ i = Math.min(i, n - c - 1)
+ while (0 <= i &&
+ (
+ target <= flowers[i] ||
+ flowers[i] * (i + 1).toLong() - prefix[i + 1] > remain
+ )
+ ) {
+ i--
+ }
+ if (0 <= i) {
+ val dif = flowers[i] * (i + 1).toLong() - prefix[i + 1]
+ min = Math.min(target - 1L, flowers[i] + (remain - dif) / (i + 1))
+ if (i + 1 < n - c) {
+ min = Math.min(min, flowers[i + 1].toLong())
+ }
+ }
+ res = Math.max(res, c * full.toLong() + min * partial)
+ }
+ return res
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2235_add_two_integers/readme.md b/src/main/kotlin/g2201_2300/s2235_add_two_integers/readme.md
new file mode 100644
index 00000000..9dadd9a4
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2235_add_two_integers/readme.md
@@ -0,0 +1,38 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2235\. Add Two Integers
+
+Easy
+
+Given two integers `num1` and `num2`, return _the **sum** of the two integers_.
+
+**Example 1:**
+
+**Input:** num1 = 12, num2 = 5
+
+**Output:** 17
+
+**Explanation:** num1 is 12, num2 is 5, and their sum is 12 + 5 = 17, so 17 is returned.
+
+**Example 2:**
+
+**Input:** num1 = -10, num2 = 4
+
+**Output:** -6
+
+**Explanation:** num1 + num2 = -6, so -6 is returned.
+
+**Constraints:**
+
+* `-100 <= num1, num2 <= 100`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun sum(num1: Int, num2: Int): Int {
+ return num1 + num2
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2236_root_equals_sum_of_children/readme.md b/src/main/kotlin/g2201_2300/s2236_root_equals_sum_of_children/readme.md
new file mode 100644
index 00000000..a97e4de7
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2236_root_equals_sum_of_children/readme.md
@@ -0,0 +1,61 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2236\. Root Equals Sum of Children
+
+Easy
+
+You are given the `root` of a **binary tree** that consists of exactly `3` nodes: the root, its left child, and its right child.
+
+Return `true` _if the value of the root is equal to the **sum** of the values of its two children, or_ `false` _otherwise_.
+
+**Example 1:**
+
+
+
+**Input:** root = [10,4,6]
+
+**Output:** true
+
+**Explanation:** The values of the root, its left child, and its right child are 10, 4, and 6, respectively.
+
+10 is equal to 4 + 6, so we return true.
+
+**Example 2:**
+
+
+
+**Input:** root = [5,3,1]
+
+**Output:** false
+
+**Explanation:** The values of the root, its left child, and its right child are 5, 3, and 1, respectively.
+
+5 is not equal to 3 + 1, so we return false.
+
+**Constraints:**
+
+* The tree consists only of the root, its left child, and its right child.
+* `-100 <= Node.val <= 100`
+
+## Solution
+
+```kotlin
+import com_github_leetcode.TreeNode
+
+/*
+ * Example:
+ * var ti = TreeNode(5)
+ * var v = ti.`val`
+ * Definition for a binary tree node.
+ * class TreeNode(var `val`: Int) {
+ * var left: TreeNode? = null
+ * var right: TreeNode? = null
+ * }
+ */
+class Solution {
+ fun checkTree(root: TreeNode): Boolean {
+ return root.left!!.`val` + root.right!!.`val` == root.`val`
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2239_find_closest_number_to_zero/readme.md b/src/main/kotlin/g2201_2300/s2239_find_closest_number_to_zero/readme.md
new file mode 100644
index 00000000..b1c8de02
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2239_find_closest_number_to_zero/readme.md
@@ -0,0 +1,59 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2239\. Find Closest Number to Zero
+
+Easy
+
+Given an integer array `nums` of size `n`, return _the number with the value **closest** to_ `0` _in_ `nums`. If there are multiple answers, return _the number with the **largest** value_.
+
+**Example 1:**
+
+**Input:** nums = [-4,-2,1,4,8]
+
+**Output:** 1
+
+**Explanation:**
+
+The distance from -4 to 0 is \|-4\| = 4.
+
+The distance from -2 to 0 is \|-2\| = 2.
+
+The distance from 1 to 0 is \|1\| = 1. The distance from 4 to 0 is \|4\| = 4.
+
+The distance from 8 to 0 is \|8\| = 8.
+
+Thus, the closest number to 0 in the array is 1.
+
+**Example 2:**
+
+**Input:** nums = [2,-1,1]
+
+**Output:** 1
+
+**Explanation:** 1 and -1 are both the closest numbers to 0, so 1 being larger is returned.
+
+**Constraints:**
+
+* `1 <= n <= 1000`
+* -105 <= nums[i] <= 105
+
+## Solution
+
+```kotlin
+class Solution {
+ fun findClosestNumber(nums: IntArray): Int {
+ var mini = Int.MAX_VALUE
+ var closestNum = 0
+ for (n in nums) {
+ if (mini > Math.abs(n)) {
+ mini = Math.abs(n)
+ closestNum = n
+ } else if (mini == Math.abs(n) && closestNum < n) {
+ closestNum = n
+ }
+ }
+ return closestNum
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2240_number_of_ways_to_buy_pens_and_pencils/readme.md b/src/main/kotlin/g2201_2300/s2240_number_of_ways_to_buy_pens_and_pencils/readme.md
new file mode 100644
index 00000000..2d4a14d2
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2240_number_of_ways_to_buy_pens_and_pencils/readme.md
@@ -0,0 +1,55 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2240\. Number of Ways to Buy Pens and Pencils
+
+Medium
+
+You are given an integer `total` indicating the amount of money you have. You are also given two integers `cost1` and `cost2` indicating the price of a pen and pencil respectively. You can spend **part or all** of your money to buy multiple quantities (or none) of each kind of writing utensil.
+
+Return _the **number of distinct ways** you can buy some number of pens and pencils._
+
+**Example 1:**
+
+**Input:** total = 20, cost1 = 10, cost2 = 5
+
+**Output:** 9
+
+**Explanation:** The price of a pen is 10 and the price of a pencil is 5.
+
+- If you buy 0 pens, you can buy 0, 1, 2, 3, or 4 pencils.
+
+- If you buy 1 pen, you can buy 0, 1, or 2 pencils.
+
+- If you buy 2 pens, you cannot buy any pencils.
+
+The total number of ways to buy pens and pencils is 5 + 3 + 1 = 9.
+
+**Example 2:**
+
+**Input:** total = 5, cost1 = 10, cost2 = 10
+
+**Output:** 1
+
+**Explanation:** The price of both pens and pencils are 10, which cost more than total, so you cannot buy any writing utensils. Therefore, there is only 1 way: buy 0 pens and 0 pencils.
+
+**Constraints:**
+
+* 1 <= total, cost1, cost2 <= 106
+
+## Solution
+
+```kotlin
+class Solution {
+ fun waysToBuyPensPencils(total: Int, cost1: Int, cost2: Int): Long {
+ var ways: Long = 0
+ var cntPen = 0
+ while (cntPen * cost1 <= total) {
+ val remMoney = total - cntPen * cost1
+ ways += (remMoney / cost2 + 1).toLong()
+ cntPen++
+ }
+ return ways
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2241_design_an_atm_machine/readme.md b/src/main/kotlin/g2201_2300/s2241_design_an_atm_machine/readme.md
new file mode 100644
index 00000000..52947831
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2241_design_an_atm_machine/readme.md
@@ -0,0 +1,99 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2241\. Design an ATM Machine
+
+Medium
+
+There is an ATM machine that stores banknotes of `5` denominations: `20`, `50`, `100`, `200`, and `500` dollars. Initially the ATM is empty. The user can use the machine to deposit or withdraw any amount of money.
+
+When withdrawing, the machine prioritizes using banknotes of **larger** values.
+
+* For example, if you want to withdraw `$300` and there are `2` `$50` banknotes, `1` `$100` banknote, and `1` `$200` banknote, then the machine will use the `$100` and `$200` banknotes.
+* However, if you try to withdraw `$600` and there are `3` `$200` banknotes and `1` `$500` banknote, then the withdraw request will be rejected because the machine will first try to use the `$500` banknote and then be unable to use banknotes to complete the remaining `$100`. Note that the machine is **not** allowed to use the `$200` banknotes instead of the `$500` banknote.
+
+Implement the ATM class:
+
+* `ATM()` Initializes the ATM object.
+* `void deposit(int[] banknotesCount)` Deposits new banknotes in the order `$20`, `$50`, `$100`, `$200`, and `$500`.
+* `int[] withdraw(int amount)` Returns an array of length `5` of the number of banknotes that will be handed to the user in the order `$20`, `$50`, `$100`, `$200`, and `$500`, and update the number of banknotes in the ATM after withdrawing. Returns `[-1]` if it is not possible (do **not** withdraw any banknotes in this case).
+
+**Example 1:**
+
+**Input**
+
+["ATM", "deposit", "withdraw", "deposit", "withdraw", "withdraw"]
+
+[[], [[0,0,1,2,1]], [600], [[0,1,0,1,1]], [600], [550]]
+
+**Output:** [null, null, [0,0,1,0,1], null, [-1], [0,1,0,0,1]]
+
+**Explanation:**
+
+ ATM atm = new ATM();
+ atm.deposit([0,0,1,2,1]); // Deposits 1 $100 banknote, 2 $200 banknotes,
+ // and 1 $500 banknote.
+ atm.withdraw(600); // Returns [0,0,1,0,1]. The machine uses 1 $100 banknote
+ // and 1 $500 banknote. The banknotes left over in the
+ // machine are [0,0,0,2,0].
+ atm.deposit([0,1,0,1,1]); // Deposits 1 $50, $200, and $500 banknote.
+ // The banknotes in the machine are now [0,1,0,3,1].
+ atm.withdraw(600); // Returns [-1]. The machine will try to use a $500 banknote
+ // and then be unable to complete the remaining $100,
+ // so the withdraw request will be rejected.
+ // Since the request is rejected, the number of banknotes
+ // in the machine is not modified.
+ atm.withdraw(550); // Returns [0,1,0,0,1]. The machine uses 1 $50 banknote
+ // and 1 $500 banknote.
+
+**Constraints:**
+
+* `banknotesCount.length == 5`
+* 0 <= banknotesCount[i] <= 109
+* 1 <= amount <= 109
+* At most `5000` calls **in total** will be made to `withdraw` and `deposit`.
+* At least **one** call will be made to each function `withdraw` and `deposit`.
+
+## Solution
+
+```kotlin
+class ATM {
+ private val nominals: IntArray = intArrayOf(20, 50, 100, 200, 500)
+ private val counts: LongArray = LongArray(5)
+
+ fun deposit(banknotesCount: IntArray) {
+ for (i in 0..4) {
+ counts[i] += banknotesCount[i].toLong()
+ }
+ }
+
+ fun withdraw(amount: Int): IntArray {
+ val delivery = IntArray(5)
+ var currentAmount = amount.toLong()
+ for (i in 4 downTo 0) {
+ if (currentAmount > nominals[i] * counts[i]) {
+ delivery[i] = counts[i].toInt()
+ } else {
+ delivery[i] = currentAmount.toInt() / nominals[i]
+ }
+ currentAmount += -nominals[i].toLong() * delivery[i]
+ if (currentAmount == 0L) {
+ break
+ }
+ }
+ if (currentAmount > 0) {
+ return intArrayOf(-1)
+ }
+ for (i in 0..4) {
+ counts[i] += -delivery[i].toLong()
+ }
+ return delivery
+ }
+}
+/*
+ * Your ATM object will be instantiated and called as such:
+ * var obj = ATM()
+ * obj.deposit(banknotesCount)
+ * var param_2 = obj.withdraw(amount)
+ */
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2242_maximum_score_of_a_node_sequence/readme.md b/src/main/kotlin/g2201_2300/s2242_maximum_score_of_a_node_sequence/readme.md
new file mode 100644
index 00000000..d183c199
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2242_maximum_score_of_a_node_sequence/readme.md
@@ -0,0 +1,132 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2242\. Maximum Score of a Node Sequence
+
+Hard
+
+There is an **undirected** graph with `n` nodes, numbered from `0` to `n - 1`.
+
+You are given a **0-indexed** integer array `scores` of length `n` where `scores[i]` denotes the score of node `i`. You are also given a 2D integer array `edges` where edges[i] = [ai, bi] denotes that there exists an **undirected** edge connecting nodes ai and bi.
+
+A node sequence is **valid** if it meets the following conditions:
+
+* There is an edge connecting every pair of **adjacent** nodes in the sequence.
+* No node appears more than once in the sequence.
+
+The score of a node sequence is defined as the **sum** of the scores of the nodes in the sequence.
+
+Return _the **maximum score** of a valid node sequence with a length of_ `4`_._ If no such sequence exists, return `-1`.
+
+**Example 1:**
+
+
+
+**Input:** scores = [5,2,9,8,4], edges = \[\[0,1],[1,2],[2,3],[0,2],[1,3],[2,4]]
+
+**Output:** 24
+
+**Explanation:** The figure above shows the graph and the chosen node sequence [0,1,2,3].
+
+The score of the node sequence is 5 + 2 + 9 + 8 = 24.
+
+It can be shown that no other node sequence has a score of more than 24.
+
+Note that the sequences [3,1,2,0] and [1,0,2,3] are also valid and have a score of 24.
+
+The sequence [0,3,2,4] is not valid since no edge connects nodes 0 and 3.
+
+**Example 2:**
+
+
+
+**Input:** scores = [9,20,6,4,11,12], edges = \[\[0,3],[5,3],[2,4],[1,3]]
+
+**Output:** -1
+
+**Explanation:** The figure above shows the graph.
+
+There are no valid node sequences of length 4, so we return -1.
+
+**Constraints:**
+
+* `n == scores.length`
+* 4 <= n <= 5 * 104
+* 1 <= scores[i] <= 108
+* 0 <= edges.length <= 5 * 104
+* `edges[i].length == 2`
+* 0 <= ai, bi <= n - 1
+* ai != bi
+* There are no duplicate edges.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun maximumScore(scores: IntArray, edges: Array): Int {
+ // store only top 3 nodes (having highest scores)
+ val graph = Array(scores.size) { IntArray(3) }
+ for (a in graph) {
+ a.fill(-1)
+ }
+ for (edge in edges) {
+ insert(edge[0], graph[edge[1]], scores)
+ insert(edge[1], graph[edge[0]], scores)
+ }
+ var maxScore = -1
+ for (edge in edges) {
+ val u = edge[0]
+ val v = edge[1]
+ val score = scores[u] + scores[v]
+ for (i in 0..2) {
+ // if neighbour is current node, skip
+ if (graph[u][i] == -1 || graph[u][i] == v) {
+ continue
+ }
+ for (j in 0..2) {
+ // if neighbour is current node or already choosen node, skip
+ if (graph[v][j] == -1 || graph[v][j] == u) {
+ continue
+ }
+ if (graph[v][j] == graph[u][i]) {
+ continue
+ }
+ maxScore = Math.max(maxScore, score + scores[graph[u][i]] + scores[graph[v][j]])
+ }
+ }
+ }
+ return maxScore
+ }
+
+ private fun insert(n: Int, arr: IntArray, scores: IntArray) {
+ if (arr[0] == -1) {
+ arr[0] = n
+ } else if (arr[1] == -1) {
+ if (scores[arr[0]] < scores[n]) {
+ arr[1] = arr[0]
+ arr[0] = n
+ } else {
+ arr[1] = n
+ }
+ } else if (arr[2] == -1) {
+ if (scores[arr[0]] < scores[n]) {
+ arr[2] = arr[1]
+ arr[1] = arr[0]
+ arr[0] = n
+ } else if (scores[arr[1]] < scores[n]) {
+ arr[2] = arr[1]
+ arr[1] = n
+ } else {
+ arr[2] = n
+ }
+ } else {
+ if (scores[arr[1]] < scores[n]) {
+ arr[2] = arr[1]
+ arr[1] = n
+ } else if (scores[arr[2]] < scores[n]) {
+ arr[2] = n
+ }
+ }
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2243_calculate_digit_sum_of_a_string/readme.md b/src/main/kotlin/g2201_2300/s2243_calculate_digit_sum_of_a_string/readme.md
new file mode 100644
index 00000000..516fa2ca
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2243_calculate_digit_sum_of_a_string/readme.md
@@ -0,0 +1,87 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2243\. Calculate Digit Sum of a String
+
+Easy
+
+You are given a string `s` consisting of digits and an integer `k`.
+
+A **round** can be completed if the length of `s` is greater than `k`. In one round, do the following:
+
+1. **Divide** `s` into **consecutive groups** of size `k` such that the first `k` characters are in the first group, the next `k` characters are in the second group, and so on. **Note** that the size of the last group can be smaller than `k`.
+2. **Replace** each group of `s` with a string representing the sum of all its digits. For example, `"346"` is replaced with `"13"` because `3 + 4 + 6 = 13`.
+3. **Merge** consecutive groups together to form a new string. If the length of the string is greater than `k`, repeat from step `1`.
+
+Return `s` _after all rounds have been completed_.
+
+**Example 1:**
+
+**Input:** s = "11111222223", k = 3
+
+**Output:** "135"
+
+**Explanation:**
+
+- For the first round, we divide s into groups of size 3: "111", "112", "222", and "23".
+
+Then we calculate the digit sum of each group: 1 + 1 + 1 = 3, 1 + 1 + 2 = 4, 2 + 2 + 2 = 6, and 2 + 3 = 5.
+
+So, s becomes "3" + "4" + "6" + "5" = "3465" after the first round.
+
+- For the second round, we divide s into "346" and "5".
+
+Then we calculate the digit sum of each group: 3 + 4 + 6 = 13, 5 = 5.
+
+So, s becomes "13" + "5" = "135" after second round.
+
+Now, s.length <= k, so we return "135" as the answer.
+
+**Example 2:**
+
+**Input:** s = "00000000", k = 3
+
+**Output:** "000"
+
+**Explanation:**
+
+We divide s into "000", "000", and "00".
+
+Then we calculate the digit sum of each group: 0 + 0 + 0 = 0, 0 + 0 + 0 = 0, and 0 + 0 = 0.
+
+s becomes "0" + "0" + "0" = "000", whose length is equal to k, so we return "000".
+
+**Constraints:**
+
+* `1 <= s.length <= 100`
+* `2 <= k <= 100`
+* `s` consists of digits only.
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ fun digitSum(s: String, k: Int): String {
+ var s = s
+ while (s.length > k) {
+ val n = s.length
+ var count = 0
+ var sum = 0
+ val sb = StringBuilder()
+ for (i in 0 until n) {
+ if (count == k) {
+ sb.append(sum)
+ sum = 0
+ count = 0
+ }
+ sum += s[i].code - '0'.code
+ count++
+ }
+ sb.append(sum)
+ s = sb.toString()
+ }
+ return s
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2244_minimum_rounds_to_complete_all_tasks/readme.md b/src/main/kotlin/g2201_2300/s2244_minimum_rounds_to_complete_all_tasks/readme.md
new file mode 100644
index 00000000..fb4a1d6b
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2244_minimum_rounds_to_complete_all_tasks/readme.md
@@ -0,0 +1,79 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2244\. Minimum Rounds to Complete All Tasks
+
+Medium
+
+You are given a **0-indexed** integer array `tasks`, where `tasks[i]` represents the difficulty level of a task. In each round, you can complete either 2 or 3 tasks of the **same difficulty level**.
+
+Return _the **minimum** rounds required to complete all the tasks, or_ `-1` _if it is not possible to complete all the tasks._
+
+**Example 1:**
+
+**Input:** tasks = [2,2,3,3,2,4,4,4,4,4]
+
+**Output:** 4
+
+**Explanation:** To complete all the tasks, a possible plan is:
+
+- In the first round, you complete 3 tasks of difficulty level 2.
+
+- In the second round, you complete 2 tasks of difficulty level 3.
+
+- In the third round, you complete 3 tasks of difficulty level 4.
+
+- In the fourth round, you complete 2 tasks of difficulty level 4.
+
+It can be shown that all the tasks cannot be completed in fewer than 4 rounds, so the answer is 4.
+
+**Example 2:**
+
+**Input:** tasks = [2,3,3]
+
+**Output:** -1
+
+**Explanation:** There is only 1 task of difficulty level 2, but in each round, you can only complete either 2 or 3 tasks of the same difficulty level. Hence, you cannot complete all the tasks, and the answer is -1.
+
+**Constraints:**
+
+* 1 <= tasks.length <= 105
+* 1 <= tasks[i] <= 109
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minimumRounds(tasks: IntArray): Int {
+ tasks.sort()
+ var rounds = 0
+ var c = 1
+ for (i in 0 until tasks.size - 1) {
+ if (tasks[i] == tasks[i + 1]) {
+ c++
+ } else {
+ if (c == 1) {
+ return -1
+ }
+ if (c % 3 == 0) {
+ rounds += c / 3
+ }
+ if (c % 3 >= 1) {
+ rounds += c / 3 + 1
+ }
+ c = 1
+ }
+ }
+ if (c == 1) {
+ return -1
+ }
+ if (c % 3 == 0) {
+ rounds += c / 3
+ }
+ if (c % 3 >= 1) {
+ rounds += c / 3 + 1
+ }
+ return rounds
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2245_maximum_trailing_zeros_in_a_cornered_path/readme.md b/src/main/kotlin/g2201_2300/s2245_maximum_trailing_zeros_in_a_cornered_path/readme.md
new file mode 100644
index 00000000..7bfe79ec
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2245_maximum_trailing_zeros_in_a_cornered_path/readme.md
@@ -0,0 +1,118 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2245\. Maximum Trailing Zeros in a Cornered Path
+
+Medium
+
+You are given a 2D integer array `grid` of size `m x n`, where each cell contains a positive integer.
+
+A **cornered path** is defined as a set of adjacent cells with **at most** one turn. More specifically, the path should exclusively move either **horizontally** or **vertically** up to the turn (if there is one), without returning to a previously visited cell. After the turn, the path will then move exclusively in the **alternate** direction: move vertically if it moved horizontally, and vice versa, also without returning to a previously visited cell.
+
+The **product** of a path is defined as the product of all the values in the path.
+
+Return _the **maximum** number of **trailing zeros** in the product of a cornered path found in_ `grid`.
+
+Note:
+
+* **Horizontal** movement means moving in either the left or right direction.
+* **Vertical** movement means moving in either the up or down direction.
+
+**Example 1:**
+
+
+
+**Input:** grid = \[\[23,17,15,3,20],[8,1,20,27,11],[9,4,6,2,21],[40,9,1,10,6],[22,7,4,5,3]]
+
+**Output:** 3
+
+**Explanation:** The grid on the left shows a valid cornered path.
+
+It has a product of 15 \* 20 \* 6 \* 1 \* 10 = 18000 which has 3 trailing zeros.
+
+It can be shown that this is the maximum trailing zeros in the product of a cornered path.
+
+
+The grid in the middle is not a cornered path as it has more than one turn.
+
+The grid on the right is not a cornered path as it requires a return to a previously visited cell.
+
+**Example 2:**
+
+
+
+**Input:** grid = \[\[4,3,2],[7,6,1],[8,8,8]]
+
+**Output:** 0
+
+**Explanation:** The grid is shown in the figure above.
+
+There are no cornered paths in the grid that result in a product with a trailing zero.
+
+**Constraints:**
+
+* `m == grid.length`
+* `n == grid[i].length`
+* 1 <= m, n <= 105
+* 1 <= m * n <= 105
+* `1 <= grid[i][j] <= 1000`
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ fun maxTrailingZeros(grid: Array): Int {
+ val m = grid.size
+ val n = grid[0].size
+ var max = 0
+ val row2 = Array(m + 1) { IntArray(n + 1) }
+ val row5 = Array(m + 1) { IntArray(n + 1) }
+ val col2 = Array(m + 1) { IntArray(n + 1) }
+ val col5 = Array(m + 1) { IntArray(n + 1) }
+ val factor2 = Array(m) { IntArray(n) }
+ val factor5 = Array(m) { IntArray(n) }
+ for (r in 0 until m) {
+ for (c in 0 until n) {
+ val factorTwo = findFactor(grid[r][c], 2)
+ val factorFive = findFactor(grid[r][c], 5)
+ row2[r + 1][c + 1] = row2[r + 1][c] + factorTwo
+ row5[r + 1][c + 1] = row5[r + 1][c] + factorFive
+ col2[r + 1][c + 1] = col2[r][c + 1] + factorTwo
+ col5[r + 1][c + 1] = col5[r][c + 1] + factorFive
+ factor2[r][c] = factorTwo
+ factor5[r][c] = factorFive
+ }
+ }
+ for (r in 0 until m) {
+ for (c in 0 until n) {
+ val cur2 = factor2[r][c]
+ val cur5 = factor5[r][c]
+ val up2 = col2[r + 1][c + 1]
+ val up5 = col5[r + 1][c + 1]
+ val down2 = col2[m][c + 1] - col2[r][c + 1]
+ val down5 = col5[m][c + 1] - col5[r][c + 1]
+ val left2 = row2[r + 1][c + 1]
+ val left5 = row5[r + 1][c + 1]
+ val right2 = row2[r + 1][n] - row2[r + 1][c]
+ val right5 = row5[r + 1][n] - row5[r + 1][c]
+ max = Math.max(max, Math.min(left2 + up2 - cur2, left5 + up5 - cur5))
+ max = Math.max(max, Math.min(right2 + up2 - cur2, right5 + up5 - cur5))
+ max = Math.max(max, Math.min(left2 + down2 - cur2, left5 + down5 - cur5))
+ max = Math.max(max, Math.min(right2 + down2 - cur2, right5 + down5 - cur5))
+ }
+ }
+ return max
+ }
+
+ private fun findFactor(a: Int, b: Int): Int {
+ var a = a
+ var factors = 0
+ while (a % b == 0) {
+ a /= b
+ factors++
+ }
+ return factors
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2246_longest_path_with_different_adjacent_characters/readme.md b/src/main/kotlin/g2201_2300/s2246_longest_path_with_different_adjacent_characters/readme.md
new file mode 100644
index 00000000..f313960a
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2246_longest_path_with_different_adjacent_characters/readme.md
@@ -0,0 +1,107 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2246\. Longest Path With Different Adjacent Characters
+
+Hard
+
+You are given a **tree** (i.e. a connected, undirected graph that has no cycles) **rooted** at node `0` consisting of `n` nodes numbered from `0` to `n - 1`. The tree is represented by a **0-indexed** array `parent` of size `n`, where `parent[i]` is the parent of node `i`. Since node `0` is the root, `parent[0] == -1`.
+
+You are also given a string `s` of length `n`, where `s[i]` is the character assigned to node `i`.
+
+Return _the length of the **longest path** in the tree such that no pair of **adjacent** nodes on the path have the same character assigned to them._
+
+**Example 1:**
+
+
+
+**Input:** parent = [-1,0,0,1,1,2], s = "abacbe"
+
+**Output:** 3
+
+**Explanation:** The longest path where each two adjacent nodes have different characters in the tree is the path: 0 -> 1 -> 3. The length of this path is 3, so 3 is returned.
+
+It can be proven that there is no longer path that satisfies the conditions.
+
+**Example 2:**
+
+
+
+**Input:** parent = [-1,0,0,0], s = "aabc"
+
+**Output:** 3
+
+**Explanation:** The longest path where each two adjacent nodes have different characters is the path: 2 -> 0 -> 3. The length of this path is 3, so 3 is returned.
+
+**Constraints:**
+
+* `n == parent.length == s.length`
+* 1 <= n <= 105
+* `0 <= parent[i] <= n - 1` for all `i >= 1`
+* `parent[0] == -1`
+* `parent` represents a valid tree.
+* `s` consists of only lowercase English letters.
+
+## Solution
+
+```kotlin
+import java.util.LinkedList
+
+class Solution {
+ fun longestPath(parent: IntArray, s: String): Int {
+ // for first max length
+ val first = IntArray(s.length)
+ first.fill(0)
+ // for second max length
+ val second = IntArray(s.length)
+ second.fill(0)
+ // for number of children for this node
+ val children = IntArray(s.length)
+ children.fill(0)
+ for (i in 1 until s.length) {
+ // calculate all children for each node
+ children[parent[i]]++
+ }
+ // for traversal from leafs to root
+ val st = LinkedList()
+ // put all leafs
+ for (i in 1 until s.length) {
+ if (children[i] == 0) {
+ st.add(i)
+ }
+ }
+ // traversal from leafs to root
+ while (st.isNotEmpty()) {
+ // fetch current node
+ val i = st.pollLast()
+ // if we in root - ignore it
+ if (i == 0) {
+ continue
+ }
+ if (--children[parent[i]] == 0) {
+ // decrease number of children by parent node and if number of children
+ st.add(parent[i])
+ }
+ // is equal 0 - our parent became a leaf
+ // if letters isn't equal
+ if (s[parent[i]] != s[i]) {
+ // fetch maximal path from node
+ val maxi = 1 + Math.max(first[i], second[i])
+ // and update maximal first and second path from parent
+ if (maxi >= first[parent[i]]) {
+ second[parent[i]] = first[parent[i]]
+ first[parent[i]] = maxi
+ } else if (second[parent[i]] < maxi) {
+ second[parent[i]] = maxi
+ }
+ }
+ }
+ // fetch answer
+ var ans = 0
+ for (i in 0 until s.length) {
+ ans = Math.max(ans, first[i] + second[i])
+ }
+ return ans + 1
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2248_intersection_of_multiple_arrays/readme.md b/src/main/kotlin/g2201_2300/s2248_intersection_of_multiple_arrays/readme.md
new file mode 100644
index 00000000..01390121
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2248_intersection_of_multiple_arrays/readme.md
@@ -0,0 +1,57 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2248\. Intersection of Multiple Arrays
+
+Easy
+
+Given a 2D integer array `nums` where `nums[i]` is a non-empty array of **distinct** positive integers, return _the list of integers that are present in **each array** of_ `nums` _sorted in **ascending order**_.
+
+**Example 1:**
+
+**Input:** nums = \[\[**3**,1,2,**4**,5],[1,2,**3**,**4**],[**3**,**4**,5,6]]
+
+**Output:** [3,4]
+
+**Explanation:**
+
+The only integers present in each of nums[0] = [**3**,1,2,**4**,5], nums[1] = [1,2,**3**,**4**], and nums[2] = [**3**,**4**,5,6] are 3 and 4, so we return [3,4].
+
+**Example 2:**
+
+**Input:** nums = \[\[1,2,3],[4,5,6]]
+
+**Output:** []
+
+**Explanation:**
+
+There does not exist any integer present both in nums[0] and nums[1], so we return an empty list [].
+
+**Constraints:**
+
+* `1 <= nums.length <= 1000`
+* `1 <= sum(nums[i].length) <= 1000`
+* `1 <= nums[i][j] <= 1000`
+* All the values of `nums[i]` are **unique**.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun intersection(nums: Array): List {
+ val ans: MutableList = ArrayList()
+ val count = IntArray(1001)
+ for (arr in nums) {
+ for (i in arr) {
+ ++count[i]
+ }
+ }
+ for (i in count.indices) {
+ if (count[i] == nums.size) {
+ ans.add(i)
+ }
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2249_count_lattice_points_inside_a_circle/readme.md b/src/main/kotlin/g2201_2300/s2249_count_lattice_points_inside_a_circle/readme.md
new file mode 100644
index 00000000..f3edd41c
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2249_count_lattice_points_inside_a_circle/readme.md
@@ -0,0 +1,85 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2249\. Count Lattice Points Inside a Circle
+
+Medium
+
+Given a 2D integer array `circles` where circles[i] = [xi, yi, ri] represents the center (xi, yi) and radius ri of the ith circle drawn on a grid, return _the **number of lattice points**_ _that are present inside **at least one** circle_.
+
+**Note:**
+
+* A **lattice point** is a point with integer coordinates.
+* Points that lie **on the circumference of a circle** are also considered to be inside it.
+
+**Example 1:**
+
+
+
+**Input:** circles = \[\[2,2,1]]
+
+**Output:** 5
+
+**Explanation:**
+
+The figure above shows the given circle.
+
+The lattice points present inside the circle are (1, 2), (2, 1), (2, 2), (2, 3), and (3, 2) and are shown in green.
+
+Other points such as (1, 1) and (1, 3), which are shown in red, are not considered inside the circle.
+
+Hence, the number of lattice points present inside at least one circle is 5.
+
+**Example 2:**
+
+
+
+**Input:** circles = \[\[2,2,2],[3,4,1]]
+
+**Output:** 16
+
+**Explanation:**
+
+The figure above shows the given circles.
+
+There are exactly 16 lattice points which are present inside at least one circle.
+
+Some of them are (0, 2), (2, 0), (2, 4), (3, 2), and (4, 4).
+
+**Constraints:**
+
+* `1 <= circles.length <= 200`
+* `circles[i].length == 3`
+* 1 <= xi, yi <= 100
+* 1 <= ri <= min(xi, yi)
+
+## Solution
+
+```kotlin
+class Solution {
+ fun countLatticePoints(circles: Array): Int {
+ var xMin = 200
+ var xMax = -1
+ var yMin = 200
+ var yMax = -1
+ for (c in circles) {
+ xMin = Math.min(xMin, c[0] - c[2])
+ xMax = Math.max(xMax, c[0] + c[2])
+ yMin = Math.min(yMin, c[1] - c[2])
+ yMax = Math.max(yMax, c[1] + c[2])
+ }
+ var ans = 0
+ for (x in xMin..xMax) {
+ for (y in yMin..yMax) {
+ for (c in circles) {
+ if ((c[0] - x) * (c[0] - x) + (c[1] - y) * (c[1] - y) <= c[2] * c[2]) {
+ ans++
+ break
+ }
+ }
+ }
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2250_count_number_of_rectangles_containing_each_point/readme.md b/src/main/kotlin/g2201_2300/s2250_count_number_of_rectangles_containing_each_point/readme.md
new file mode 100644
index 00000000..6f44d5a6
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2250_count_number_of_rectangles_containing_each_point/readme.md
@@ -0,0 +1,98 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2250\. Count Number of Rectangles Containing Each Point
+
+Medium
+
+You are given a 2D integer array `rectangles` where rectangles[i] = [li, hi] indicates that ith rectangle has a length of li and a height of hi. You are also given a 2D integer array `points` where points[j] = [xj, yj] is a point with coordinates (xj, yj).
+
+The ith rectangle has its **bottom-left corner** point at the coordinates `(0, 0)` and its **top-right corner** point at (li, hi).
+
+Return _an integer array_ `count` _of length_ `points.length` _where_ `count[j]` _is the number of rectangles that **contain** the_ jth _point._
+
+The ith rectangle **contains** the jth point if 0 <= xj <= li and 0 <= yj <= hi. Note that points that lie on the **edges** of a rectangle are also considered to be contained by that rectangle.
+
+**Example 1:**
+
+
+
+**Input:** rectangles = \[\[1,2],[2,3],[2,5]], points = \[\[2,1],[1,4]]
+
+**Output:** [2,1]
+
+**Explanation:**
+
+The first rectangle contains no points.
+
+The second rectangle contains only the point (2, 1).
+
+The third rectangle contains the points (2, 1) and (1, 4).
+
+The number of rectangles that contain the point (2, 1) is 2.
+
+The number of rectangles that contain the point (1, 4) is 1.
+
+Therefore, we return [2, 1].
+
+**Example 2:**
+
+
+
+**Input:** rectangles = \[\[1,1],[2,2],[3,3]], points = \[\[1,3],[1,1]]
+
+**Output:** [1,3]
+
+**Explanation:**
+
+The first rectangle contains only the point (1, 1).
+
+The second rectangle contains only the point (1, 1).
+
+The third rectangle contains the points (1, 3) and (1, 1).
+
+The number of rectangles that contain the point (1, 3) is 1.
+
+The number of rectangles that contain the point (1, 1) is 3.
+
+Therefore, we return [1, 3].
+
+**Constraints:**
+
+* 1 <= rectangles.length, points.length <= 5 * 104
+* `rectangles[i].length == points[j].length == 2`
+* 1 <= li, xj <= 109
+* 1 <= hi, yj <= 100
+* All the `rectangles` are **unique**.
+* All the `points` are **unique**.
+
+## Solution
+
+```kotlin
+import java.util.Arrays
+
+class Solution {
+ fun countRectangles(rectangles: Array, points: Array): IntArray {
+ val n = rectangles.size
+ val q = points.size
+ val es = arrayOfNulls(n + q)
+ System.arraycopy(rectangles, 0, es, 0, n)
+ for (i in 0 until q) {
+ es[n + i] = intArrayOf(points[i][0], points[i][1], i)
+ }
+ Arrays.sort(es) { x: IntArray?, y: IntArray? -> if (x!![0] != y!![0]) -(x[0] - y[0]) else x.size - y.size }
+ val ct = IntArray(101)
+ val ans = IntArray(q)
+ for (e in es) {
+ if (e!!.size == 2) {
+ for (i in 0..e[1]) {
+ ct[i]++
+ }
+ } else {
+ ans[e[2]] = ct[e[1]]
+ }
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2251_number_of_flowers_in_full_bloom/readme.md b/src/main/kotlin/g2201_2300/s2251_number_of_flowers_in_full_bloom/readme.md
new file mode 100644
index 00000000..ccfb1ed6
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2251_number_of_flowers_in_full_bloom/readme.md
@@ -0,0 +1,85 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2251\. Number of Flowers in Full Bloom
+
+Hard
+
+You are given a **0-indexed** 2D integer array `flowers`, where flowers[i] = [starti, endi] means the ith flower will be in **full bloom** from starti to endi (**inclusive**). You are also given a **0-indexed** integer array `persons` of size `n`, where `persons[i]` is the time that the ith person will arrive to see the flowers.
+
+Return _an integer array_ `answer` _of size_ `n`_, where_ `answer[i]` _is the **number** of flowers that are in full bloom when the_ ith _person arrives._
+
+**Example 1:**
+
+
+
+**Input:** flowers = \[\[1,6],[3,7],[9,12],[4,13]], persons = [2,3,7,11]
+
+**Output:** [1,2,2,2]
+
+**Explanation:** The figure above shows the times when the flowers are in full bloom and when the people arrive. For each person, we return the number of flowers in full bloom during their arrival.
+
+**Example 2:**
+
+
+
+**Input:** flowers = \[\[1,10],[3,3]], persons = [3,3,2]
+
+**Output:** [2,2,1]
+
+**Explanation:** The figure above shows the times when the flowers are in full bloom and when the people arrive. For each person, we return the number of flowers in full bloom during their arrival.
+
+**Constraints:**
+
+* 1 <= flowers.length <= 5 * 104
+* `flowers[i].length == 2`
+* 1 <= starti <= endi <= 109
+* 1 <= persons.length <= 5 * 104
+* 1 <= persons[i] <= 109
+
+## Solution
+
+```kotlin
+import java.util.Arrays
+import java.util.PriorityQueue
+
+class Solution {
+ fun fullBloomFlowers(flowers: Array, persons: IntArray): IntArray {
+ Arrays.sort(flowers, { a: IntArray, b: IntArray -> a[0].compareTo(b[0]) })
+ val ans = IntArray(persons.size)
+ val pq = PriorityQueue({ a: Pair, b: Pair -> a.j.compareTo(b.j) })
+ var j = 0
+ val t = Array(persons.size) { IntArray(2) }
+ for (i in persons.indices) {
+ t[i][0] = persons[i]
+ t[i][1] = i
+ }
+ Arrays.sort(t, { a: IntArray, b: IntArray -> a[0].compareTo(b[0]) })
+ for (ints in t) {
+ while (pq.isNotEmpty()) {
+ if (pq.peek().j < ints[0]) {
+ pq.poll()
+ } else {
+ break
+ }
+ }
+ while (j < flowers.size) {
+ if (flowers[j][0] <= ints[0] && flowers[j][1] >= ints[0]) {
+ pq.add(Pair(flowers[j][0], flowers[j][1]))
+ j++
+ continue
+ }
+ if (flowers[j][1] < ints[0]) {
+ j++
+ continue
+ }
+ break
+ }
+ ans[ints[1]] = pq.size
+ }
+ return ans
+ }
+
+ private class Pair(var i: Int, var j: Int)
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2255_count_prefixes_of_a_given_string/readme.md b/src/main/kotlin/g2201_2300/s2255_count_prefixes_of_a_given_string/readme.md
new file mode 100644
index 00000000..6f03415f
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2255_count_prefixes_of_a_given_string/readme.md
@@ -0,0 +1,60 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2255\. Count Prefixes of a Given String
+
+Easy
+
+You are given a string array `words` and a string `s`, where `words[i]` and `s` comprise only of **lowercase English letters**.
+
+Return _the **number of strings** in_ `words` _that are a **prefix** of_ `s`.
+
+A **prefix** of a string is a substring that occurs at the beginning of the string. A **substring** is a contiguous sequence of characters within a string.
+
+**Example 1:**
+
+**Input:** words = ["a","b","c","ab","bc","abc"], s = "abc"
+
+**Output:** 3
+
+**Explanation:**
+
+The strings in words which are a prefix of s = "abc" are:
+
+"a", "ab", and "abc".
+
+Thus the number of strings in words which are a prefix of s is 3.
+
+**Example 2:**
+
+**Input:** words = ["a","a"], s = "aa"
+
+**Output:** 2
+
+**Explanation:**
+
+Both of the strings are a prefix of s.
+
+Note that the same string can occur multiple times in words, and it should be counted each time.
+
+**Constraints:**
+
+* `1 <= words.length <= 1000`
+* `1 <= words[i].length, s.length <= 10`
+* `words[i]` and `s` consist of lowercase English letters **only**.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun countPrefixes(words: Array, s: String): Int {
+ var count = 0
+ for (str in words) {
+ if (s.indexOf(str) == 0) {
+ ++count
+ }
+ }
+ return count
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2256_minimum_average_difference/readme.md b/src/main/kotlin/g2201_2300/s2256_minimum_average_difference/readme.md
new file mode 100644
index 00000000..37087930
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2256_minimum_average_difference/readme.md
@@ -0,0 +1,86 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2256\. Minimum Average Difference
+
+Medium
+
+You are given a **0-indexed** integer array `nums` of length `n`.
+
+The **average difference** of the index `i` is the **absolute** **difference** between the average of the **first** `i + 1` elements of `nums` and the average of the **last** `n - i - 1` elements. Both averages should be **rounded down** to the nearest integer.
+
+Return _the index with the **minimum average difference**_. If there are multiple such indices, return the **smallest** one.
+
+**Note:**
+
+* The **absolute difference** of two numbers is the absolute value of their difference.
+* The **average** of `n` elements is the **sum** of the `n` elements divided (**integer division**) by `n`.
+* The average of `0` elements is considered to be `0`.
+
+**Example 1:**
+
+**Input:** nums = [2,5,3,9,5,3]
+
+**Output:** 3
+
+**Explanation:**
+
+- The average difference of index 0 is: \|2 / 1 - (5 + 3 + 9 + 5 + 3) / 5\| = \|2 / 1 - 25 / 5\| = \|2 - 5\| = 3.
+
+- The average difference of index 1 is: \|(2 + 5) / 2 - (3 + 9 + 5 + 3) / 4\| = \|7 / 2 - 20 / 4\| = \|3 - 5\| = 2.
+
+- The average difference of index 2 is: \|(2 + 5 + 3) / 3 - (9 + 5 + 3) / 3\| = \|10 / 3 - 17 / 3\| = \|3 - 5\| = 2.
+
+- The average difference of index 3 is: \|(2 + 5 + 3 + 9) / 4 - (5 + 3) / 2\| = \|19 / 4 - 8 / 2\| = \|4 - 4\| = 0.
+
+- The average difference of index 4 is: \|(2 + 5 + 3 + 9 + 5) / 5 - 3 / 1\| = \|24 / 5 - 3 / 1\| = \|4 - 3\| = 1.
+
+- The average difference of index 5 is: \|(2 + 5 + 3 + 9 + 5 + 3) / 6 - 0\| = \|27 / 6 - 0\| = \|4 - 0\| = 4.
+
+The average difference of index 3 is the minimum average difference so return 3.
+
+**Example 2:**
+
+**Input:** nums = [0]
+
+**Output:** 0
+
+**Explanation:**
+
+The only index is 0 so return 0.
+
+The average difference of index 0 is: \|0 / 1 - 0\| = \|0 - 0\| = 0.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* 0 <= nums[i] <= 105
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minimumAverageDifference(nums: IntArray): Int {
+ var numsSum: Long = 0
+ for (num in nums) {
+ numsSum += num.toLong()
+ }
+ var minAverageDiff = Long.MAX_VALUE
+ var sumFromFront: Long = 0
+ var index = 0
+ for (i in nums.indices) {
+ sumFromFront += nums[i].toLong()
+ val numbersRight = if (i == nums.size - 1) 1 else nums.size - i - 1
+ val averageDiff = Math.abs(sumFromFront / (i + 1) - (numsSum - sumFromFront) / numbersRight)
+ if (minAverageDiff > averageDiff) {
+ minAverageDiff = averageDiff
+ index = i
+ }
+ if (averageDiff == 0L) {
+ break
+ }
+ }
+ return index
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2257_count_unguarded_cells_in_the_grid/readme.md b/src/main/kotlin/g2201_2300/s2257_count_unguarded_cells_in_the_grid/readme.md
new file mode 100644
index 00000000..a3107ce3
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2257_count_unguarded_cells_in_the_grid/readme.md
@@ -0,0 +1,135 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2257\. Count Unguarded Cells in the Grid
+
+Medium
+
+You are given two integers `m` and `n` representing a **0-indexed** `m x n` grid. You are also given two 2D integer arrays `guards` and `walls` where guards[i] = [rowi, coli] and walls[j] = [rowj, colj] represent the positions of the ith guard and jth wall respectively.
+
+A guard can see **every** cell in the four cardinal directions (north, east, south, or west) starting from their position unless **obstructed** by a wall or another guard. A cell is **guarded** if there is **at least** one guard that can see it.
+
+Return _the number of unoccupied cells that are **not** **guarded**._
+
+**Example 1:**
+
+
+
+**Input:** m = 4, n = 6, guards = \[\[0,0],[1,1],[2,3]], walls = \[\[0,1],[2,2],[1,4]]
+
+**Output:** 7
+
+**Explanation:** The guarded and unguarded cells are shown in red and green respectively in the above diagram. There are a total of 7 unguarded cells, so we return 7.
+
+**Example 2:**
+
+
+
+**Input:** m = 3, n = 3, guards = \[\[1,1]], walls = \[\[0,1],[1,0],[2,1],[1,2]]
+
+**Output:** 4
+
+**Explanation:** The unguarded cells are shown in green in the above diagram. There are a total of 4 unguarded cells, so we return 4.
+
+**Constraints:**
+
+* 1 <= m, n <= 105
+* 2 <= m * n <= 105
+* 1 <= guards.length, walls.length <= 5 * 104
+* `2 <= guards.length + walls.length <= m * n`
+* `guards[i].length == walls[j].length == 2`
+* 0 <= rowi, rowj < m
+* 0 <= coli, colj < n
+* All the positions in `guards` and `walls` are **unique**.
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ fun countUnguarded(m: Int, n: Int, guards: Array, walls: Array): Int {
+ val matrix = Array(m) { CharArray(n) }
+ var result = 0
+ for (i in guards.indices) {
+ val guardRow = guards[i][0]
+ val guardCol = guards[i][1]
+ matrix[guardRow][guardCol] = 'G'
+ }
+ for (i in walls.indices) {
+ val wallRow = walls[i][0]
+ val wallCol = walls[i][1]
+ matrix[wallRow][wallCol] = 'W'
+ }
+ for (i in guards.indices) {
+ var currentRow = guards[i][0]
+ var currentCol = guards[i][1] - 1
+ extracted(matrix, currentRow, currentCol)
+ currentRow = guards[i][0]
+ currentCol = guards[i][1] + 1
+ extracted(n, matrix, currentRow, currentCol)
+ currentRow = guards[i][0] - 1
+ currentCol = guards[i][1]
+ extracted1(matrix, currentRow, currentCol)
+ currentRow = guards[i][0] + 1
+ currentCol = guards[i][1]
+ extracted1(m, matrix, currentRow, currentCol)
+ }
+ for (i in 0 until m) {
+ for (j in 0 until n) {
+ if (matrix[i][j] != 'R' && matrix[i][j] != 'G' && matrix[i][j] != 'W') {
+ result++
+ }
+ }
+ }
+ return result
+ }
+
+ private fun extracted1(m: Int, matrix: Array, currentRow: Int, currentCol: Int) {
+ var currentRow = currentRow
+ while (currentRow <= m - 1) {
+ if (matrix[currentRow][currentCol] != 'W' && matrix[currentRow][currentCol] != 'G') {
+ matrix[currentRow][currentCol] = 'R'
+ } else {
+ break
+ }
+ currentRow++
+ }
+ }
+
+ private fun extracted1(matrix: Array, currentRow: Int, currentCol: Int) {
+ var currentRow = currentRow
+ while (currentRow >= 0) {
+ if (matrix[currentRow][currentCol] != 'W' && matrix[currentRow][currentCol] != 'G') {
+ matrix[currentRow][currentCol] = 'R'
+ } else {
+ break
+ }
+ currentRow--
+ }
+ }
+
+ private fun extracted(n: Int, matrix: Array, currentRow: Int, currentCol: Int) {
+ var currentCol = currentCol
+ while (currentCol <= n - 1) {
+ if (matrix[currentRow][currentCol] != 'W' && matrix[currentRow][currentCol] != 'G') {
+ matrix[currentRow][currentCol] = 'R'
+ } else {
+ break
+ }
+ currentCol++
+ }
+ }
+
+ private fun extracted(matrix: Array, currentRow: Int, currentCol: Int) {
+ var currentCol = currentCol
+ while (currentCol >= 0) {
+ if (matrix[currentRow][currentCol] != 'W' && matrix[currentRow][currentCol] != 'G') {
+ matrix[currentRow][currentCol] = 'R'
+ } else {
+ break
+ }
+ currentCol--
+ }
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2258_escape_the_spreading_fire/readme.md b/src/main/kotlin/g2201_2300/s2258_escape_the_spreading_fire/readme.md
new file mode 100644
index 00000000..67a70c3e
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2258_escape_the_spreading_fire/readme.md
@@ -0,0 +1,166 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2258\. Escape the Spreading Fire
+
+Hard
+
+You are given a **0-indexed** 2D integer array `grid` of size `m x n` which represents a field. Each cell has one of three values:
+
+* `0` represents grass,
+* `1` represents fire,
+* `2` represents a wall that you and fire cannot pass through.
+
+You are situated in the top-left cell, `(0, 0)`, and you want to travel to the safehouse at the bottom-right cell, `(m - 1, n - 1)`. Every minute, you may move to an **adjacent** grass cell. **After** your move, every fire cell will spread to all **adjacent** cells that are not walls.
+
+Return _the **maximum** number of minutes that you can stay in your initial position before moving while still safely reaching the safehouse_. If this is impossible, return `-1`. If you can **always** reach the safehouse regardless of the minutes stayed, return 109.
+
+Note that even if the fire spreads to the safehouse immediately after you have reached it, it will be counted as safely reaching the safehouse.
+
+A cell is **adjacent** to another cell if the former is directly north, east, south, or west of the latter (i.e., their sides are touching).
+
+**Example 1:**
+
+
+
+**Input:** grid = \[\[0,2,0,0,0,0,0],[0,0,0,2,2,1,0],[0,2,0,0,1,2,0],[0,0,2,2,2,0,2],[0,0,0,0,0,0,0]]
+
+**Output:** 3
+
+**Explanation:** The figure above shows the scenario where you stay in the initial position for 3 minutes.
+
+You will still be able to safely reach the safehouse.
+
+Staying for more than 3 minutes will not allow you to safely reach the safehouse.
+
+**Example 2:**
+
+
+
+**Input:** grid = \[\[0,0,0,0],[0,1,2,0],[0,2,0,0]]
+
+**Output:** -1
+
+**Explanation:** The figure above shows the scenario where you immediately move towards the safehouse.
+
+Fire will spread to any cell you move towards and it is impossible to safely reach the safehouse.
+
+Thus, -1 is returned.
+
+**Example 3:**
+
+
+
+**Input:** grid = \[\[0,0,0],[2,2,0],[1,2,0]]
+
+**Output:** 1000000000
+
+**Explanation:** The figure above shows the initial grid. Notice that the fire is contained by walls and you will always be able to safely reach the safehouse. Thus, 109 is returned.
+
+**Constraints:**
+
+* `m == grid.length`
+* `n == grid[i].length`
+* `2 <= m, n <= 300`
+* 4 <= m * n <= 2 * 104
+* `grid[i][j]` is either `0`, `1`, or `2`.
+* `grid[0][0] == grid[m - 1][n - 1] == 0`
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ private fun setFire(grid: Array, dir: Array): Array {
+ val n = grid.size
+ val m = grid[0].size
+ val bfs = ArrayDeque()
+ val fire = Array(n) { IntArray(m) }
+ for (i in 0 until n) {
+ for (j in 0 until m) {
+ fire[i][j] = Int.MAX_VALUE
+ if (grid[i][j] == 1) {
+ fire[i][j] = 0
+ bfs.add(i * m + j)
+ }
+ if (grid[i][j] == 2) {
+ fire[i][j] = 0
+ }
+ }
+ }
+ while (bfs.isNotEmpty()) {
+ val rm = bfs.removeFirst()
+ val x = rm / m
+ val y = rm % m
+ for (d in 0..3) {
+ val nx = x + dir[d][0]
+ val ny = y + dir[d][1]
+ if (nx >= 0 && ny >= 0 && nx < n && ny < m && fire[nx][ny] == Int.MAX_VALUE) {
+ fire[nx][ny] = fire[x][y] + 1
+ bfs.add(nx * m + ny)
+ }
+ }
+ }
+ return fire
+ }
+
+ private fun isPoss(fire: Array, dir: Array, time: Int): Boolean {
+ var time = time
+ if (time >= fire[0][0]) {
+ return false
+ }
+ val n = fire.size
+ val m = fire[0].size
+ val bfs = ArrayDeque()
+ bfs.add(0)
+ val isVis = Array(n) { BooleanArray(m) }
+ isVis[0][0] = true
+ while (bfs.isNotEmpty()) {
+ var size = bfs.size
+ while (size-- > 0) {
+ val rm = bfs.removeFirst()
+ val x = rm / m
+ val y = rm % m
+ if (x == n - 1 && y == m - 1) {
+ return true
+ }
+ for (d in 0..3) {
+ val nx = x + dir[d][0]
+ val ny = y + dir[d][1]
+ if (nx >= 0 && ny >= 0 && nx < n && ny < m && !isVis[nx][ny]) {
+ if (nx == n - 1 && ny == m - 1) {
+ if (time + 1 <= fire[nx][ny]) {
+ isVis[nx][ny] = true
+ bfs.add(nx * m + ny)
+ }
+ } else {
+ if (time + 1 < fire[nx][ny]) {
+ isVis[nx][ny] = true
+ bfs.add(nx * m + ny)
+ }
+ }
+ }
+ }
+ }
+ time++
+ }
+ return false
+ }
+
+ fun maximumMinutes(grid: Array): Int {
+ val dir = arrayOf(intArrayOf(0, 1), intArrayOf(1, 0), intArrayOf(-1, 0), intArrayOf(0, -1))
+ val fire = setFire(grid, dir)
+ var lo = 0
+ var hi = 1e9.toInt()
+ while (lo <= hi) {
+ val mid = (hi - lo shr 1) + lo
+ if (isPoss(fire, dir, mid)) {
+ lo = mid + 1
+ } else {
+ hi = mid - 1
+ }
+ }
+ return hi
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2259_remove_digit_from_number_to_maximize_result/readme.md b/src/main/kotlin/g2201_2300/s2259_remove_digit_from_number_to_maximize_result/readme.md
new file mode 100644
index 00000000..1a20fd58
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2259_remove_digit_from_number_to_maximize_result/readme.md
@@ -0,0 +1,68 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2259\. Remove Digit From Number to Maximize Result
+
+Easy
+
+You are given a string `number` representing a **positive integer** and a character `digit`.
+
+Return _the resulting string after removing **exactly one occurrence** of_ `digit` _from_ `number` _such that the value of the resulting string in **decimal** form is **maximized**_. The test cases are generated such that `digit` occurs at least once in `number`.
+
+**Example 1:**
+
+**Input:** number = "123", digit = "3"
+
+**Output:** "12"
+
+**Explanation:** There is only one '3' in "123". After removing '3', the result is "12".
+
+**Example 2:**
+
+**Input:** number = "1231", digit = "1"
+
+**Output:** "231"
+
+**Explanation:** We can remove the first '1' to get "231" or remove the second '1' to get "123".
+
+Since 231 > 123, we return "231".
+
+**Example 3:**
+
+**Input:** number = "551", digit = "5"
+
+**Output:** "51"
+
+**Explanation:** We can remove either the first or second '5' from "551".
+
+Both result in the string "51".
+
+**Constraints:**
+
+* `2 <= number.length <= 100`
+* `number` consists of digits from `'1'` to `'9'`.
+* `digit` is a digit from `'1'` to `'9'`.
+* `digit` occurs at least once in `number`.
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ fun removeDigit(number: String, digit: Char): String {
+ var number = number
+ var index = 0
+ val n = number.length
+ for (i in 0 until n) {
+ if (number[i] == digit) {
+ index = i
+ if (i < n - 1 && digit < number[i + 1]) {
+ break
+ }
+ }
+ }
+ number = number.substring(0, index) + number.substring(index + 1)
+ return number
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2260_minimum_consecutive_cards_to_pick_up/readme.md b/src/main/kotlin/g2201_2300/s2260_minimum_consecutive_cards_to_pick_up/readme.md
new file mode 100644
index 00000000..9ae41537
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2260_minimum_consecutive_cards_to_pick_up/readme.md
@@ -0,0 +1,55 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2260\. Minimum Consecutive Cards to Pick Up
+
+Medium
+
+You are given an integer array `cards` where `cards[i]` represents the **value** of the ith card. A pair of cards are **matching** if the cards have the **same** value.
+
+Return _the **minimum** number of **consecutive** cards you have to pick up to have a pair of **matching** cards among the picked cards._ If it is impossible to have matching cards, return `-1`.
+
+**Example 1:**
+
+**Input:** cards = [3,4,2,3,4,7]
+
+**Output:** 4
+
+**Explanation:** We can pick up the cards [3,4,2,3] which contain a matching pair of cards with value 3.
+
+Note that picking up the cards [4,2,3,4] is also optimal.
+
+**Example 2:**
+
+**Input:** cards = [1,0,5,3]
+
+**Output:** -1
+
+**Explanation:** There is no way to pick up a set of consecutive cards that contain a pair of matching cards.
+
+**Constraints:**
+
+* 1 <= cards.length <= 105
+* 0 <= cards[i] <= 106
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minimumCardPickup(cards: IntArray): Int {
+ var mindiff = Int.MAX_VALUE
+ val map: MutableMap = HashMap()
+ val n = cards.size
+ for (i in 0 until n) {
+ if (map.containsKey(cards[i])) {
+ val j = map[cards[i]]!!
+ mindiff = Math.min(mindiff, i - j + 1)
+ }
+ map[cards[i]] = i
+ }
+ return if (mindiff == Int.MAX_VALUE) {
+ -1
+ } else mindiff
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2261_k_divisible_elements_subarrays/readme.md b/src/main/kotlin/g2201_2300/s2261_k_divisible_elements_subarrays/readme.md
new file mode 100644
index 00000000..6e30e813
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2261_k_divisible_elements_subarrays/readme.md
@@ -0,0 +1,79 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2261\. K Divisible Elements Subarrays
+
+Medium
+
+Given an integer array `nums` and two integers `k` and `p`, return _the number of **distinct subarrays** which have **at most**_ `k` _elements divisible by_ `p`.
+
+Two arrays `nums1` and `nums2` are said to be **distinct** if:
+
+* They are of **different** lengths, or
+* There exists **at least** one index `i` where `nums1[i] != nums2[i]`.
+
+A **subarray** is defined as a **non-empty** contiguous sequence of elements in an array.
+
+**Example 1:**
+
+**Input:** nums = [**2**,3,3,**2**,**2**], k = 2, p = 2
+
+**Output:** 11
+
+**Explanation:**
+
+The elements at indices 0, 3, and 4 are divisible by p = 2.
+
+The 11 distinct subarrays which have at most k = 2 elements divisible by 2 are:
+
+[2], [2,3], [2,3,3], [2,3,3,2], [3], [3,3], [3,3,2], [3,3,2,2], [3,2], [3,2,2], and [2,2].
+
+Note that the subarrays [2] and [3] occur more than once in nums, but they should each be counted only once.
+
+The subarray [2,3,3,2,2] should not be counted because it has 3 elements that are divisible by 2.
+
+**Example 2:**
+
+**Input:** nums = [1,2,3,4], k = 4, p = 1
+
+**Output:** 10
+
+**Explanation:**
+
+All element of nums are divisible by p = 1.
+
+Also, every subarray of nums will have at most 4 elements that are divisible by 1.
+
+Since all subarrays are distinct, the total number of subarrays satisfying all the constraints is 10.
+
+**Constraints:**
+
+* `1 <= nums.length <= 200`
+* `1 <= nums[i], p <= 200`
+* `1 <= k <= nums.length`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun countDistinct(nums: IntArray, k: Int, p: Int): Int {
+ val numSubarray = HashSet()
+ for (i in nums.indices) {
+ var countDiv = 0
+ var hashCode: Long = 1
+ for (j in i until nums.size) {
+ hashCode = 199L * hashCode + nums[j]
+ if (nums[j] % p == 0) {
+ countDiv++
+ }
+ if (countDiv <= k) {
+ numSubarray.add(hashCode)
+ } else {
+ break
+ }
+ }
+ }
+ return numSubarray.size
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2262_total_appeal_of_a_string/readme.md b/src/main/kotlin/g2201_2300/s2262_total_appeal_of_a_string/readme.md
new file mode 100644
index 00000000..a05a7ec9
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2262_total_appeal_of_a_string/readme.md
@@ -0,0 +1,76 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2262\. Total Appeal of A String
+
+Hard
+
+The **appeal** of a string is the number of **distinct** characters found in the string.
+
+* For example, the appeal of `"abbca"` is `3` because it has `3` distinct characters: `'a'`, `'b'`, and `'c'`.
+
+Given a string `s`, return _the **total appeal of all of its **substrings**.**_
+
+A **substring** is a contiguous sequence of characters within a string.
+
+**Example 1:**
+
+**Input:** s = "abbca"
+
+**Output:** 28
+
+**Explanation:** The following are the substrings of "abbca":
+
+- Substrings of length 1: "a", "b", "b", "c", "a" have an appeal of 1, 1, 1, 1, and 1 respectively. The sum is 5.
+
+- Substrings of length 2: "ab", "bb", "bc", "ca" have an appeal of 2, 1, 2, and 2 respectively. The sum is 7.
+
+- Substrings of length 3: "abb", "bbc", "bca" have an appeal of 2, 2, and 3 respectively. The sum is 7.
+
+- Substrings of length 4: "abbc", "bbca" have an appeal of 3 and 3 respectively. The sum is 6.
+
+- Substrings of length 5: "abbca" has an appeal of 3. The sum is 3.
+
+The total sum is 5 + 7 + 7 + 6 + 3 = 28.
+
+**Example 2:**
+
+**Input:** s = "code"
+
+**Output:** 20
+
+**Explanation:** The following are the substrings of "code":
+
+- Substrings of length 1: "c", "o", "d", "e" have an appeal of 1, 1, 1, and 1 respectively. The sum is 4.
+
+- Substrings of length 2: "co", "od", "de" have an appeal of 2, 2, and 2 respectively. The sum is 6.
+
+- Substrings of length 3: "cod", "ode" have an appeal of 3 and 3 respectively. The sum is 6.
+
+- Substrings of length 4: "code" has an appeal of 4. The sum is 4.
+
+The total sum is 4 + 6 + 6 + 4 = 20.
+
+**Constraints:**
+
+* 1 <= s.length <= 105
+* `s` consists of lowercase English letters.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun appealSum(s: String): Long {
+ val len = s.length
+ val lastPos = IntArray(26)
+ lastPos.fill(-1)
+ var res: Long = 0
+ for (i in 0 until len) {
+ val idx = s[i].code - 'a'.code
+ res += ((i - lastPos[idx]) * (len - i)).toLong()
+ lastPos[idx] = i
+ }
+ return res
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2264_largest_3_same_digit_number_in_string/readme.md b/src/main/kotlin/g2201_2300/s2264_largest_3_same_digit_number_in_string/readme.md
new file mode 100644
index 00000000..9531e107
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2264_largest_3_same_digit_number_in_string/readme.md
@@ -0,0 +1,72 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2264\. Largest 3-Same-Digit Number in String
+
+Easy
+
+You are given a string `num` representing a large integer. An integer is **good** if it meets the following conditions:
+
+* It is a **substring** of `num` with length `3`.
+* It consists of only one unique digit.
+
+Return _the **maximum good** integer as a **string** or an empty string_ `""` _if no such integer exists_.
+
+Note:
+
+* A **substring** is a contiguous sequence of characters within a string.
+* There may be **leading zeroes** in `num` or a good integer.
+
+**Example 1:**
+
+**Input:** num = "6**777**133339"
+
+**Output:** "777"
+
+**Explanation:** There are two distinct good integers: "777" and "333".
+
+"777" is the largest, so we return "777".
+
+**Example 2:**
+
+**Input:** num = "23**000**19"
+
+**Output:** "000"
+
+**Explanation:** "000" is the only good integer.
+
+**Example 3:**
+
+**Input:** num = "42352338"
+
+**Output:** ""
+
+**Explanation:** No substring of length 3 consists of only one unique digit. Therefore, there are no good integers.
+
+**Constraints:**
+
+* `3 <= num.length <= 1000`
+* `num` only consists of digits.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun largestGoodInteger(num: String): String {
+ var maxi = "000"
+ var c = 0
+ for (i in 0 until num.length - 2) {
+ val s = num.substring(i, i + 3)
+ if (s[0] == s[1] && s[1] == s[2]) {
+ if (s.compareTo(maxi) >= 0) {
+ maxi = s
+ }
+ ++c
+ }
+ }
+ return if (c == 0) {
+ ""
+ } else maxi
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2265_count_nodes_equal_to_average_of_subtree/readme.md b/src/main/kotlin/g2201_2300/s2265_count_nodes_equal_to_average_of_subtree/readme.md
new file mode 100644
index 00000000..07668955
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2265_count_nodes_equal_to_average_of_subtree/readme.md
@@ -0,0 +1,86 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2265\. Count Nodes Equal to Average of Subtree
+
+Medium
+
+Given the `root` of a binary tree, return _the number of nodes where the value of the node is equal to the **average** of the values in its **subtree**_.
+
+**Note:**
+
+* The **average** of `n` elements is the **sum** of the `n` elements divided by `n` and **rounded down** to the nearest integer.
+* A **subtree** of `root` is a tree consisting of `root` and all of its descendants.
+
+**Example 1:**
+
+
+
+**Input:** root = [4,8,5,0,1,null,6]
+
+**Output:** 5
+
+**Explanation:**
+
+For the node with value 4: The average of its subtree is (4 + 8 + 5 + 0 + 1 + 6) / 6 = 24 / 6 = 4.
+
+For the node with value 5: The average of its subtree is (5 + 6) / 2 = 11 / 2 = 5.
+
+For the node with value 0: The average of its subtree is 0 / 1 = 0.
+
+For the node with value 1: The average of its subtree is 1 / 1 = 1.
+
+For the node with value 6: The average of its subtree is 6 / 1 = 6.
+
+**Example 2:**
+
+
+
+**Input:** root = [1]
+
+**Output:** 1
+
+**Explanation:** For the node with value 1: The average of its subtree is 1 / 1 = 1.
+
+**Constraints:**
+
+* The number of nodes in the tree is in the range `[1, 1000]`.
+* `0 <= Node.val <= 1000`
+
+## Solution
+
+```kotlin
+import com_github_leetcode.TreeNode
+
+/*
+ * Example:
+ * var ti = TreeNode(5)
+ * var v = ti.`val`
+ * Definition for a binary tree node.
+ * class TreeNode(var `val`: Int) {
+ * var left: TreeNode? = null
+ * var right: TreeNode? = null
+ * }
+ */
+class Solution {
+ private var ans = 0
+ fun averageOfSubtree(root: TreeNode?): Int {
+ dfs(root)
+ return ans
+ }
+
+ private fun dfs(node: TreeNode?): IntArray {
+ if (node == null) {
+ return intArrayOf(0, 0)
+ }
+ val left = dfs(node.left)
+ val right = dfs(node.right)
+ val currsum = left[0] + right[0] + node.`val`
+ val currcount = left[1] + right[1] + 1
+ if (currsum / currcount == node.`val`) {
+ ++ans
+ }
+ return intArrayOf(currsum, currcount)
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2266_count_number_of_texts/readme.md b/src/main/kotlin/g2201_2300/s2266_count_number_of_texts/readme.md
new file mode 100644
index 00000000..b91ee499
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2266_count_number_of_texts/readme.md
@@ -0,0 +1,93 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2266\. Count Number of Texts
+
+Medium
+
+Alice is texting Bob using her phone. The **mapping** of digits to letters is shown in the figure below.
+
+
+
+In order to **add** a letter, Alice has to **press** the key of the corresponding digit `i` times, where `i` is the position of the letter in the key.
+
+* For example, to add the letter `'s'`, Alice has to press `'7'` four times. Similarly, to add the letter `'k'`, Alice has to press `'5'` twice.
+* Note that the digits `'0'` and `'1'` do not map to any letters, so Alice **does not** use them.
+
+However, due to an error in transmission, Bob did not receive Alice's text message but received a **string of pressed keys** instead.
+
+* For example, when Alice sent the message `"bob"`, Bob received the string `"2266622"`.
+
+Given a string `pressedKeys` representing the string received by Bob, return _the **total number of possible text messages** Alice could have sent_.
+
+Since the answer may be very large, return it **modulo** 109 + 7.
+
+**Example 1:**
+
+**Input:** pressedKeys = "22233"
+
+**Output:** 8
+
+**Explanation:**
+
+The possible text messages Alice could have sent are:
+
+"aaadd", "abdd", "badd", "cdd", "aaae", "abe", "bae", and "ce".
+
+Since there are 8 possible messages, we return 8.
+
+**Example 2:**
+
+**Input:** pressedKeys = "222222222222222222222222222222222222"
+
+**Output:** 82876089
+
+**Explanation:** There are 2082876103 possible text messages Alice could have sent.
+
+Since we need to return the answer modulo 109 + 7, we return 2082876103 % (109 + 7) = 82876089.
+
+**Constraints:**
+
+* 1 <= pressedKeys.length <= 105
+* `pressedKeys` only consists of digits from `'2'` - `'9'`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun countTexts(pressedKeys: String): Int {
+ val len = pressedKeys.length
+ var dp0 = 1L
+ var dp1: Long = 0
+ var dp2: Long = 0
+ var dp3: Long = 0
+ var dp4: Long
+ val keys = pressedKeys.toCharArray()
+ val base = 1000000007
+ for (i in 1 until len) {
+ val r = keys[i].code - '0'.code
+ dp4 = dp3
+ dp3 = dp2
+ dp2 = dp1
+ dp1 = dp0 % base
+ dp0 = dp1
+ dp0 += (if (i - 1 == 0 && keys[i] == keys[i - 1]) 1 else 0).toLong()
+ if (i - 1 <= 0 || keys[i] != keys[i - 1]) {
+ continue
+ }
+ dp0 += dp2
+ dp0 += (if (i - 2 == 0 && keys[i] == keys[i - 2]) 1 else 0).toLong()
+ if (i - 2 <= 0 || keys[i] != keys[i - 2]) {
+ continue
+ }
+ dp0 += dp3
+ dp0 += (if (i - 3 == 0 && keys[i] == keys[i - 3] && (r == 7 || r == 9)) 1 else 0).toLong()
+ if (i - 3 <= 0 || keys[i] != keys[i - 3] || r != 7 && r != 9) {
+ continue
+ }
+ dp0 += dp4
+ }
+ return (dp0 % base).toInt()
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2267_check_if_there_is_a_valid_parentheses_string_path/readme.md b/src/main/kotlin/g2201_2300/s2267_check_if_there_is_a_valid_parentheses_string_path/readme.md
new file mode 100644
index 00000000..11a6c093
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2267_check_if_there_is_a_valid_parentheses_string_path/readme.md
@@ -0,0 +1,119 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2267\. Check if There Is a Valid Parentheses String Path
+
+Hard
+
+A parentheses string is a **non-empty** string consisting only of `'('` and `')'`. It is **valid** if **any** of the following conditions is **true**:
+
+* It is `()`.
+* It can be written as `AB` (`A` concatenated with `B`), where `A` and `B` are valid parentheses strings.
+* It can be written as `(A)`, where `A` is a valid parentheses string.
+
+You are given an `m x n` matrix of parentheses `grid`. A **valid parentheses string path** in the grid is a path satisfying **all** of the following conditions:
+
+* The path starts from the upper left cell `(0, 0)`.
+* The path ends at the bottom-right cell `(m - 1, n - 1)`.
+* The path only ever moves **down** or **right**.
+* The resulting parentheses string formed by the path is **valid**.
+
+Return `true` _if there exists a **valid parentheses string path** in the grid._ Otherwise, return `false`.
+
+**Example 1:**
+
+
+
+**Input:** grid = \[\["(","(","("],[")","(",")"],["(","(",")"],["(","(",")"]]
+
+**Output:** true
+
+**Explanation:** The above diagram shows two possible paths that form valid parentheses strings.
+
+The first path shown results in the valid parentheses string "()(())".
+
+The second path shown results in the valid parentheses string "((()))".
+
+Note that there may be other valid parentheses string paths.
+
+**Example 2:**
+
+
+
+**Input:** grid = \[\[")",")"],["(","("]]
+
+**Output:** false
+
+**Explanation:** The two possible paths form the parentheses strings "))(" and ")((". Since neither of them are valid parentheses strings, we return false.
+
+**Constraints:**
+
+* `m == grid.length`
+* `n == grid[i].length`
+* `1 <= m, n <= 100`
+* `grid[i][j]` is either `'('` or `')'`.
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ private lateinit var grid: Array
+ private var m = 0
+ private var n = 0
+
+ fun hasValidPath(grid: Array): Boolean {
+ this.grid = grid
+ m = grid.size
+ n = grid[0].size
+ val dp = Array(m) { Array(n) { arrayOfNulls(m + n + 1) } }
+ if (grid[0][0] == RGTPAR) {
+ return false
+ }
+ return if ((m + n) % 2 == 0) {
+ false
+ } else dfs(0, 0, 0, 0, dp)
+ }
+
+ private fun dfs(u: Int, v: Int, open: Int, close: Int, dp: Array>>): Boolean {
+ var open = open
+ var close = close
+ if (grid[u][v] == LFTPAR) {
+ open++
+ } else {
+ close++
+ }
+ if (u == m - 1 && v == n - 1) {
+ return open == close
+ }
+ if (open < close) {
+ return false
+ }
+ if (dp[u][v][open - close] != null) {
+ return dp[u][v][open - close]!!
+ }
+ if (u == m - 1) {
+ val result = dfs(u, v + 1, open, close, dp)
+ dp[u][v][open - close] = result
+ return result
+ }
+ if (v == n - 1) {
+ return dfs(u + 1, v, open, close, dp)
+ }
+ val rslt: Boolean
+ rslt =
+ if (grid[u][v] == LFTPAR) {
+ dfs(u + 1, v, open, close, dp) || dfs(u, v + 1, open, close, dp)
+ } else {
+ dfs(u, v + 1, open, close, dp) || dfs(u + 1, v, open, close, dp)
+ }
+ dp[u][v][open - close] = rslt
+ return rslt
+ }
+
+ companion object {
+ private const val LFTPAR = '('
+ private const val RGTPAR = ')'
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2269_find_the_k_beauty_of_a_number/readme.md b/src/main/kotlin/g2201_2300/s2269_find_the_k_beauty_of_a_number/readme.md
new file mode 100644
index 00000000..4b57ce6f
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2269_find_the_k_beauty_of_a_number/readme.md
@@ -0,0 +1,88 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2269\. Find the K-Beauty of a Number
+
+Easy
+
+The **k-beauty** of an integer `num` is defined as the number of **substrings** of `num` when it is read as a string that meet the following conditions:
+
+* It has a length of `k`.
+* It is a divisor of `num`.
+
+Given integers `num` and `k`, return _the k-beauty of_ `num`.
+
+Note:
+
+* **Leading zeros** are allowed.
+* `0` is not a divisor of any value.
+
+A **substring** is a contiguous sequence of characters in a string.
+
+**Example 1:**
+
+**Input:** num = 240, k = 2
+
+**Output:** 2
+
+**Explanation:** The following are the substrings of num of length k:
+
+- "24" from "**24**0": 24 is a divisor of 240.
+
+- "40" from "2**40**": 40 is a divisor of 240.
+
+Therefore, the k-beauty is 2.
+
+**Example 2:**
+
+**Input:** num = 430043, k = 2
+
+**Output:** 2
+
+**Explanation:** The following are the substrings of num of length k:
+
+- "43" from "**43**0043": 43 is a divisor of 430043.
+
+- "30" from "4**30**043": 30 is not a divisor of 430043.
+
+- "00" from "43**00**43": 0 is not a divisor of 430043.
+
+- "04" from "430**04**3": 4 is not a divisor of 430043.
+
+- "43" from "4300**43**": 43 is a divisor of 430043.
+
+Therefore, the k-beauty is 2.
+
+**Constraints:**
+
+* 1 <= num <= 109
+* `1 <= k <= num.length` (taking `num` as a string)
+
+## Solution
+
+```kotlin
+class Solution {
+ fun divisorSubstrings(num: Int, k: Int): Int {
+ var i = 0
+ var j = 0
+ var count = 0
+ val s = num.toString()
+ val sb = StringBuilder()
+ while (i < s.length && j < s.length) {
+ sb.append(s[j].code - '0'.code)
+ val `val` = sb.toString().toInt()
+ if (j - i + 1 == k) {
+ if (`val` != 0 && num % `val` == 0) {
+ count++
+ }
+ sb.deleteCharAt(0)
+ i++
+ j++
+ } else {
+ j++
+ }
+ }
+ return count
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2270_number_of_ways_to_split_array/readme.md b/src/main/kotlin/g2201_2300/s2270_number_of_ways_to_split_array/readme.md
new file mode 100644
index 00000000..7286d2cb
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2270_number_of_ways_to_split_array/readme.md
@@ -0,0 +1,69 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2270\. Number of Ways to Split Array
+
+Medium
+
+You are given a **0-indexed** integer array `nums` of length `n`.
+
+`nums` contains a **valid split** at index `i` if the following are true:
+
+* The sum of the first `i + 1` elements is **greater than or equal to** the sum of the last `n - i - 1` elements.
+* There is **at least one** element to the right of `i`. That is, `0 <= i < n - 1`.
+
+Return _the number of **valid splits** in_ `nums`.
+
+**Example 1:**
+
+**Input:** nums = [10,4,-8,7]
+
+**Output:** 2
+
+**Explanation:** There are three ways of splitting nums into two non-empty parts:
+
+- Split nums at index 0. Then, the first part is [10], and its sum is 10. The second part is [4,-8,7], and its sum is 3. Since 10 >= 3, i = 0 is a valid split.
+
+- Split nums at index 1. Then, the first part is [10,4], and its sum is 14. The second part is [-8,7], and its sum is -1. Since 14 >= -1, i = 1 is a valid split.
+
+- Split nums at index 2. Then, the first part is [10,4,-8], and its sum is 6. The second part is [7], and its sum is 7. Since 6 < 7, i = 2 is not a valid split. Thus, the number of valid splits in nums is 2.
+
+**Example 2:**
+
+**Input:** nums = [2,3,1,0]
+
+**Output:** 2
+
+**Explanation:** There are two valid splits in nums:
+
+- Split nums at index 1. Then, the first part is [2,3], and its sum is 5. The second part is [1,0], and its sum is 1. Since 5 >= 1, i = 1 is a valid split.
+
+- Split nums at index 2. Then, the first part is [2,3,1], and its sum is 6. The second part is [0], and its sum is 0. Since 6 >= 0, i = 2 is a valid split.
+
+**Constraints:**
+
+* 2 <= nums.length <= 105
+* -105 <= nums[i] <= 105
+
+## Solution
+
+```kotlin
+class Solution {
+ fun waysToSplitArray(nums: IntArray): Int {
+ var leftSum: Long = 0
+ var rightSum: Long = 0
+ for (i in nums) {
+ rightSum += i.toLong()
+ }
+ var count = 0
+ for (i in 0 until nums.size - 1) {
+ rightSum -= nums[i].toLong()
+ leftSum += nums[i].toLong()
+ if (leftSum >= rightSum) {
+ count++
+ }
+ }
+ return count
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2271_maximum_white_tiles_covered_by_a_carpet/readme.md b/src/main/kotlin/g2201_2300/s2271_maximum_white_tiles_covered_by_a_carpet/readme.md
new file mode 100644
index 00000000..2fc022b8
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2271_maximum_white_tiles_covered_by_a_carpet/readme.md
@@ -0,0 +1,77 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2271\. Maximum White Tiles Covered by a Carpet
+
+Medium
+
+You are given a 2D integer array `tiles` where tiles[i] = [li, ri] represents that every tile `j` in the range li <= j <= ri is colored white.
+
+You are also given an integer `carpetLen`, the length of a single carpet that can be placed **anywhere**.
+
+Return _the **maximum** number of white tiles that can be covered by the carpet_.
+
+**Example 1:**
+
+
+
+**Input:** tiles = \[\[1,5],[10,11],[12,18],[20,25],[30,32]], carpetLen = 10
+
+**Output:** 9
+
+**Explanation:** Place the carpet starting on tile 10.
+
+It covers 9 white tiles, so we return 9.
+
+Note that there may be other places where the carpet covers 9 white tiles.
+
+It can be shown that the carpet cannot cover more than 9 white tiles.
+
+**Example 2:**
+
+
+
+**Input:** tiles = \[\[10,11],[1,1]], carpetLen = 2
+
+**Output:** 2
+
+**Explanation:** Place the carpet starting on tile 10.
+
+It covers 2 white tiles, so we return 2.
+
+**Constraints:**
+
+* 1 <= tiles.length <= 5 * 104
+* `tiles[i].length == 2`
+* 1 <= li <= ri <= 109
+* 1 <= carpetLen <= 109
+* The `tiles` are **non-overlapping**.
+
+## Solution
+
+```kotlin
+import java.util.Arrays
+
+class Solution {
+ fun maximumWhiteTiles(tiles: Array, carpetLength: Int): Int {
+ Arrays.sort(tiles, { x: IntArray, y: IntArray -> x[0].compareTo(y[0]) })
+ var currentCover = Math.min(tiles[0][1] - tiles[0][0] + 1, carpetLength)
+ var maxCover = currentCover
+ var head = 1
+ var tail = 0
+ while (tail < tiles.size && head < tiles.size && maxCover < carpetLength) {
+ if (tiles[head][1] - tiles[tail][0] + 1 <= carpetLength) {
+ currentCover += tiles[head][1] - tiles[head][0] + 1
+ maxCover = Math.max(maxCover, currentCover)
+ ++head
+ } else {
+ val possiblePartialCoverOverCurrentHead = carpetLength - (tiles[head][0] - tiles[tail][0])
+ maxCover = Math.max(maxCover, currentCover + possiblePartialCoverOverCurrentHead)
+ currentCover = currentCover - (tiles[tail][1] - tiles[tail][0] + 1)
+ ++tail
+ }
+ }
+ return maxCover
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2272_substring_with_largest_variance/readme.md b/src/main/kotlin/g2201_2300/s2272_substring_with_largest_variance/readme.md
new file mode 100644
index 00000000..91b1b7fc
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2272_substring_with_largest_variance/readme.md
@@ -0,0 +1,86 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2272\. Substring With Largest Variance
+
+Hard
+
+The **variance** of a string is defined as the largest difference between the number of occurrences of **any** `2` characters present in the string. Note the two characters may or may not be the same.
+
+Given a string `s` consisting of lowercase English letters only, return _the **largest variance** possible among all **substrings** of_ `s`.
+
+A **substring** is a contiguous sequence of characters within a string.
+
+**Example 1:**
+
+**Input:** s = "aababbb"
+
+**Output:** 3
+
+**Explanation:** All possible variances along with their respective substrings are listed below:
+
+- Variance 0 for substrings "a", "aa", "ab", "abab", "aababb", "ba", "b", "bb", and "bbb".
+
+- Variance 1 for substrings "aab", "aba", "abb", "aabab", "ababb", "aababbb", and "bab".
+
+- Variance 2 for substrings "aaba", "ababbb", "abbb", and "babb".
+
+- Variance 3 for substring "babbb".
+
+Since the largest possible variance is 3, we return it.
+
+**Example 2:**
+
+**Input:** s = "abcde"
+
+**Output:** 0
+
+**Explanation:** No letter occurs more than once in s, so the variance of every substring is 0.
+
+**Constraints:**
+
+* 1 <= s.length <= 104
+* `s` consists of lowercase English letters.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun largestVariance(s: String): Int {
+ val freq = IntArray(26)
+ for (i in 0 until s.length) {
+ freq[s[i].code - 'a'.code]++
+ }
+ var maxVariance = 0
+ for (a in 0..25) {
+ for (b in 0..25) {
+ var remainingA = freq[a]
+ val remainingB = freq[b]
+ if (a == b || remainingA == 0 || remainingB == 0) {
+ continue
+ }
+ var currBFreq = 0
+ var currAFreq = 0
+ for (i in 0 until s.length) {
+ val c = s[i].code - 'a'.code
+ if (c == b) {
+ currBFreq++
+ }
+ if (c == a) {
+ currAFreq++
+ remainingA--
+ }
+ if (currAFreq > 0) {
+ maxVariance = Math.max(maxVariance, currBFreq - currAFreq)
+ }
+ if (currBFreq < currAFreq && remainingA >= 1) {
+ currBFreq = 0
+ currAFreq = 0
+ }
+ }
+ }
+ }
+ return maxVariance
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2273_find_resultant_array_after_removing_anagrams/readme.md b/src/main/kotlin/g2201_2300/s2273_find_resultant_array_after_removing_anagrams/readme.md
new file mode 100644
index 00000000..18de49e1
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2273_find_resultant_array_after_removing_anagrams/readme.md
@@ -0,0 +1,89 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2273\. Find Resultant Array After Removing Anagrams
+
+Easy
+
+You are given a **0-indexed** string array `words`, where `words[i]` consists of lowercase English letters.
+
+In one operation, select any index `i` such that `0 < i < words.length` and `words[i - 1]` and `words[i]` are **anagrams**, and **delete** `words[i]` from `words`. Keep performing this operation as long as you can select an index that satisfies the conditions.
+
+Return `words` _after performing all operations_. It can be shown that selecting the indices for each operation in **any** arbitrary order will lead to the same result.
+
+An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase using all the original letters exactly once. For example, `"dacb"` is an anagram of `"abdc"`.
+
+**Example 1:**
+
+**Input:** words = ["abba","baba","bbaa","cd","cd"]
+
+**Output:** ["abba","cd"]
+
+**Explanation:** One of the ways we can obtain the resultant array is by using the following operations:
+
+- Since words[2] = "bbaa" and words[1] = "baba" are anagrams, we choose index 2 and delete words[2]. Now words = ["abba","baba","cd","cd"].
+
+- Since words[1] = "baba" and words[0] = "abba" are anagrams, we choose index 1 and delete words[1]. Now words = ["abba","cd","cd"].
+
+- Since words[2] = "cd" and words[1] = "cd" are anagrams, we choose index 2 and delete words[2]. Now words = ["abba","cd"].
+
+We can no longer perform any operations, so ["abba","cd"] is the final answer.
+
+**Example 2:**
+
+**Input:** words = ["a","b","c","d","e"]
+
+**Output:** ["a","b","c","d","e"]
+
+**Explanation:** No two adjacent strings in words are anagrams of each other, so no operations are performed.
+
+**Constraints:**
+
+* `1 <= words.length <= 100`
+* `1 <= words[i].length <= 10`
+* `words[i]` consists of lowercase English letters.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun removeAnagrams(words: Array): List {
+ val result: MutableList = ArrayList()
+ if (words.isEmpty()) {
+ return result
+ }
+ var uniqueWordIdx = 0
+ var currIdx = 1
+ result.add(words[uniqueWordIdx])
+ while (currIdx < words.size) {
+ if (!isAnagram(words[currIdx], words[uniqueWordIdx])) {
+ uniqueWordIdx = currIdx
+ result.add(words[uniqueWordIdx])
+ }
+ currIdx++
+ }
+ return result
+ }
+
+ /*
+ Utility to check if the 2 words are anagrams or not
+ */
+ private fun isAnagram(word1: String, word2: String): Boolean {
+ val charMap = IntArray(26)
+ val word1Arr = word1.toCharArray()
+ val word2Arr = word2.toCharArray()
+ for (a in word1Arr) {
+ charMap[a.code - 'a'.code]++
+ }
+ for (a in word2Arr) {
+ charMap[a.code - 'a'.code]--
+ }
+ for (a in charMap) {
+ if (a != 0) {
+ return false
+ }
+ }
+ return true
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2274_maximum_consecutive_floors_without_special_floors/readme.md b/src/main/kotlin/g2201_2300/s2274_maximum_consecutive_floors_without_special_floors/readme.md
new file mode 100644
index 00000000..83c0bace
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2274_maximum_consecutive_floors_without_special_floors/readme.md
@@ -0,0 +1,66 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2274\. Maximum Consecutive Floors Without Special Floors
+
+Medium
+
+Alice manages a company and has rented some floors of a building as office space. Alice has decided some of these floors should be **special floors**, used for relaxation only.
+
+You are given two integers `bottom` and `top`, which denote that Alice has rented all the floors from `bottom` to `top` (**inclusive**). You are also given the integer array `special`, where `special[i]` denotes a special floor that Alice has designated for relaxation.
+
+Return _the **maximum** number of consecutive floors without a special floor_.
+
+**Example 1:**
+
+**Input:** bottom = 2, top = 9, special = [4,6]
+
+**Output:** 3
+
+**Explanation:** The following are the ranges (inclusive) of consecutive floors without a special floor:
+
+- (2, 3) with a total amount of 2 floors.
+
+- (5, 5) with a total amount of 1 floor.
+
+- (7, 9) with a total amount of 3 floors.
+
+Therefore, we return the maximum number which is 3 floors.
+
+**Example 2:**
+
+**Input:** bottom = 6, top = 8, special = [7,6,8]
+
+**Output:** 0
+
+**Explanation:** Every floor rented is a special floor, so we return 0.
+
+**Constraints:**
+
+* 1 <= special.length <= 105
+* 1 <= bottom <= special[i] <= top <= 109
+* All the values of `special` are **unique**.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun maxConsecutive(bottom: Int, top: Int, special: IntArray): Int {
+ special.sort()
+ var start = bottom
+ var ans = 0
+ for (j in special) {
+ if (j - start > ans) {
+ ans = j - start
+ start = j + 1
+ } else {
+ start = j + 1
+ }
+ }
+ if (ans < top - special[special.size - 1]) {
+ ans = top - special[special.size - 1]
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2275_largest_combination_with_bitwise_and_greater_than_zero/readme.md b/src/main/kotlin/g2201_2300/s2275_largest_combination_with_bitwise_and_greater_than_zero/readme.md
new file mode 100644
index 00000000..9610971d
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2275_largest_combination_with_bitwise_and_greater_than_zero/readme.md
@@ -0,0 +1,70 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2275\. Largest Combination With Bitwise AND Greater Than Zero
+
+Medium
+
+The **bitwise AND** of an array `nums` is the bitwise AND of all integers in `nums`.
+
+* For example, for `nums = [1, 5, 3]`, the bitwise AND is equal to `1 & 5 & 3 = 1`.
+* Also, for `nums = [7]`, the bitwise AND is `7`.
+
+You are given an array of positive integers `candidates`. Evaluate the **bitwise AND** of every **combination** of numbers of `candidates`. Each number in `candidates` may only be used **once** in each combination.
+
+Return _the size of the **largest** combination of_ `candidates` _with a bitwise AND **greater** than_ `0`.
+
+**Example 1:**
+
+**Input:** candidates = [16,17,71,62,12,24,14]
+
+**Output:** 4
+
+**Explanation:** The combination [16,17,62,24] has a bitwise AND of 16 & 17 & 62 & 24 = 16 > 0.
+
+The size of the combination is 4.
+
+It can be shown that no combination with a size greater than 4 has a bitwise AND greater than 0.
+
+Note that more than one combination may have the largest size.
+
+For example, the combination [62,12,24,14] has a bitwise AND of 62 & 12 & 24 & 14 = 8 > 0.
+
+**Example 2:**
+
+**Input:** candidates = [8,8]
+
+**Output:** 2
+
+**Explanation:** The largest combination [8,8] has a bitwise AND of 8 & 8 = 8 > 0.
+
+The size of the combination is 2, so we return 2.
+
+**Constraints:**
+
+* 1 <= candidates.length <= 105
+* 1 <= candidates[i] <= 107
+
+## Solution
+
+```kotlin
+class Solution {
+ fun largestCombination(candidates: IntArray): Int {
+ val bits = IntArray(32)
+ for (x in candidates) {
+ var i = 0
+ var localX = x
+ while (localX != 0) {
+ bits[i] += localX and 1
+ i++
+ localX = localX shr 1
+ }
+ }
+ var ans = 0
+ for (b in bits) {
+ ans = Math.max(ans, b)
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2276_count_integers_in_intervals/readme.md b/src/main/kotlin/g2201_2300/s2276_count_integers_in_intervals/readme.md
new file mode 100644
index 00000000..4de09ff4
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2276_count_integers_in_intervals/readme.md
@@ -0,0 +1,93 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2276\. Count Integers in Intervals
+
+Hard
+
+Given an **empty** set of intervals, implement a data structure that can:
+
+* **Add** an interval to the set of intervals.
+* **Count** the number of integers that are present in **at least one** interval.
+
+Implement the `CountIntervals` class:
+
+* `CountIntervals()` Initializes the object with an empty set of intervals.
+* `void add(int left, int right)` Adds the interval `[left, right]` to the set of intervals.
+* `int count()` Returns the number of integers that are present in **at least one** interval.
+
+**Note** that an interval `[left, right]` denotes all the integers `x` where `left <= x <= right`.
+
+**Example 1:**
+
+**Input**
+
+["CountIntervals", "add", "add", "count", "add", "count"]
+
+[[], [2, 3], [7, 10], [], [5, 8], []]
+
+**Output:** [null, null, null, 6, null, 8]
+
+**Explanation:**
+
+ CountIntervals countIntervals = new CountIntervals(); // initialize the object with an empty set of intervals.
+ countIntervals.add(2, 3); // add [2, 3] to the set of intervals.
+ countIntervals.add(7, 10); // add [7, 10] to the set of intervals.
+ countIntervals.count(); // return 6
+ // the integers 2 and 3 are present in the interval [2, 3].
+ // the integers 7, 8, 9, and 10 are present in the interval [7, 10].
+ countIntervals.add(5, 8); // add [5, 8] to the set of intervals.
+ countIntervals.count(); // return 8
+ // the integers 2 and 3 are present in the interval [2, 3].
+ // the integers 5 and 6 are present in the interval [5, 8].
+ // the integers 7 and 8 are present in the intervals [5, 8] and [7, 10].
+ // the integers 9 and 10 are present in the interval [7, 10].
+
+**Constraints:**
+
+* 1 <= left <= right <= 109
+* At most 105 calls **in total** will be made to `add` and `count`.
+* At least **one** call will be made to `count`.
+
+## Solution
+
+```kotlin
+import java.util.TreeMap
+
+@Suppress("NAME_SHADOWING")
+class CountIntervals {
+ private val map: TreeMap = TreeMap()
+ private var count: Int
+
+ init {
+ map[-1] = -1
+ map[1000000001] = 1000000001
+ count = 0
+ }
+
+ fun add(left: Int, right: Int) {
+ var left = left
+ var right = right
+ var item = if (map.floorEntry(left).value < left) map.ceilingEntry(left) else map.floorEntry(left)
+ while (item.key <= right) {
+ left = Math.min(left, item.key)
+ right = Math.max(right, item.value)
+ count -= item.value - item.key + 1
+ map.remove(item.key)
+ item = map.ceilingEntry(item.key)
+ }
+ map[left] = right
+ count += right - left + 1
+ }
+
+ fun count(): Int {
+ return count
+ }
+}
+/*
+ * Your CountIntervals object will be instantiated and called as such:
+ * var obj = CountIntervals()
+ * obj.add(left,right)
+ * var param_2 = obj.count()
+ */
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2278_percentage_of_letter_in_string/readme.md b/src/main/kotlin/g2201_2300/s2278_percentage_of_letter_in_string/readme.md
new file mode 100644
index 00000000..9f042d06
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2278_percentage_of_letter_in_string/readme.md
@@ -0,0 +1,51 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2278\. Percentage of Letter in String
+
+Easy
+
+Given a string `s` and a character `letter`, return _the **percentage** of characters in_ `s` _that equal_ `letter` _**rounded down** to the nearest whole percent._
+
+**Example 1:**
+
+**Input:** s = "foobar", letter = "o"
+
+**Output:** 33
+
+**Explanation:**
+
+The percentage of characters in s that equal the letter 'o' is 2 / 6 \* 100% = 33% when rounded down, so we return 33.
+
+**Example 2:**
+
+**Input:** s = "jjjj", letter = "k"
+
+**Output:** 0
+
+**Explanation:**
+
+The percentage of characters in s that equal the letter 'k' is 0%, so we return 0.
+
+**Constraints:**
+
+* `1 <= s.length <= 100`
+* `s` consists of lowercase English letters.
+* `letter` is a lowercase English letter.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun percentageLetter(s: String, letter: Char): Int {
+ var count = 0
+ val n = s.length
+ for (i in 0 until n) {
+ if (s[i] == letter) {
+ ++count
+ }
+ }
+ return count * 100 / n
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2279_maximum_bags_with_full_capacity_of_rocks/readme.md b/src/main/kotlin/g2201_2300/s2279_maximum_bags_with_full_capacity_of_rocks/readme.md
new file mode 100644
index 00000000..eccd589f
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2279_maximum_bags_with_full_capacity_of_rocks/readme.md
@@ -0,0 +1,84 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2279\. Maximum Bags With Full Capacity of Rocks
+
+Medium
+
+You have `n` bags numbered from `0` to `n - 1`. You are given two **0-indexed** integer arrays `capacity` and `rocks`. The ith bag can hold a maximum of `capacity[i]` rocks and currently contains `rocks[i]` rocks. You are also given an integer `additionalRocks`, the number of additional rocks you can place in **any** of the bags.
+
+Return _the **maximum** number of bags that could have full capacity after placing the additional rocks in some bags._
+
+**Example 1:**
+
+**Input:** capacity = [2,3,4,5], rocks = [1,2,4,4], additionalRocks = 2
+
+**Output:** 3
+
+**Explanation:**
+
+Place 1 rock in bag 0 and 1 rock in bag 1.
+
+The number of rocks in each bag are now [2,3,4,4].
+
+Bags 0, 1, and 2 have full capacity.
+
+There are 3 bags at full capacity, so we return 3.
+
+It can be shown that it is not possible to have more than 3 bags at full capacity.
+
+Note that there may be other ways of placing the rocks that result in an answer of 3.
+
+**Example 2:**
+
+**Input:** capacity = [10,2,2], rocks = [2,2,0], additionalRocks = 100
+
+**Output:** 3
+
+**Explanation:**
+
+Place 8 rocks in bag 0 and 2 rocks in bag 2.
+
+The number of rocks in each bag are now [10,2,2].
+
+Bags 0, 1, and 2 have full capacity.
+
+There are 3 bags at full capacity, so we return 3.
+
+It can be shown that it is not possible to have more than 3 bags at full capacity.
+
+Note that we did not use all of the additional rocks.
+
+**Constraints:**
+
+* `n == capacity.length == rocks.length`
+* 1 <= n <= 5 * 104
+* 1 <= capacity[i] <= 109
+* `0 <= rocks[i] <= capacity[i]`
+* 1 <= additionalRocks <= 109
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ fun maximumBags(capacity: IntArray, rocks: IntArray, additionalRocks: Int): Int {
+ var additionalRocks = additionalRocks
+ val len = capacity.size
+ for (i in 0 until len) {
+ capacity[i] -= rocks[i]
+ }
+ capacity.sort()
+ var total = 0
+ var i = 0
+ while (i < len && additionalRocks > 0) {
+ if (capacity[i] <= additionalRocks) {
+ additionalRocks -= capacity[i]
+ total++
+ }
+ i++
+ }
+ return total
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2280_minimum_lines_to_represent_a_line_chart/readme.md b/src/main/kotlin/g2201_2300/s2280_minimum_lines_to_represent_a_line_chart/readme.md
new file mode 100644
index 00000000..b99e14d8
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2280_minimum_lines_to_represent_a_line_chart/readme.md
@@ -0,0 +1,87 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2280\. Minimum Lines to Represent a Line Chart
+
+Medium
+
+You are given a 2D integer array `stockPrices` where stockPrices[i] = [dayi, pricei] indicates the price of the stock on day dayi is pricei. A **line chart** is created from the array by plotting the points on an XY plane with the X-axis representing the day and the Y-axis representing the price and connecting adjacent points. One such example is shown below:
+
+
+
+Return _the **minimum number of lines** needed to represent the line chart_.
+
+**Example 1:**
+
+
+
+**Input:** stockPrices = \[\[1,7],[2,6],[3,5],[4,4],[5,4],[6,3],[7,2],[8,1]]
+
+**Output:** 3
+
+**Explanation:**
+
+The diagram above represents the input, with the X-axis representing the day and Y-axis representing the price.
+
+The following 3 lines can be drawn to represent the line chart:
+
+- Line 1 (in red) from (1,7) to (4,4) passing through (1,7), (2,6), (3,5), and (4,4).
+
+- Line 2 (in blue) from (4,4) to (5,4).
+
+- Line 3 (in green) from (5,4) to (8,1) passing through (5,4), (6,3), (7,2), and (8,1).
+
+It can be shown that it is not possible to represent the line chart using less than 3 lines.
+
+**Example 2:**
+
+
+
+**Input:** stockPrices = \[\[3,4],[1,2],[7,8],[2,3]]
+
+**Output:** 1
+
+**Explanation:** As shown in the diagram above, the line chart can be represented with a single line.
+
+**Constraints:**
+
+* 1 <= stockPrices.length <= 105
+* `stockPrices[i].length == 2`
+* 1 <= dayi, pricei <= 109
+* All dayi are **distinct**.
+
+## Solution
+
+```kotlin
+import java.util.Arrays
+
+class Solution {
+ fun minimumLines(stockPrices: Array): Int {
+ if (stockPrices.size == 1) {
+ return 0
+ }
+ Arrays.sort(stockPrices) { a: IntArray, b: IntArray -> a[0] - b[0] }
+ // multiply with 1.0 to make it double and multiply with 100 for making it big so that
+ // difference won't come out to be very less and after division it become 0.
+ // failing for one of the case without multiply 100
+ var lastSlope = (
+ (stockPrices[1][1] - stockPrices[0][1]) *
+ 100 /
+ ((stockPrices[1][0] - stockPrices[0][0]) * 1.0)
+ )
+ var ans = 1
+ for (i in 2 until stockPrices.size) {
+ val curSlope = (
+ (stockPrices[i][1] - stockPrices[i - 1][1]) *
+ 100 /
+ ((stockPrices[i][0] - stockPrices[i - 1][0]) * 1.0)
+ )
+ if (lastSlope != curSlope) {
+ lastSlope = curSlope
+ ans++
+ }
+ }
+ return ans
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2281_sum_of_total_strength_of_wizards/readme.md b/src/main/kotlin/g2201_2300/s2281_sum_of_total_strength_of_wizards/readme.md
new file mode 100644
index 00000000..7ba60779
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2281_sum_of_total_strength_of_wizards/readme.md
@@ -0,0 +1,182 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2281\. Sum of Total Strength of Wizards
+
+Hard
+
+As the ruler of a kingdom, you have an army of wizards at your command.
+
+You are given a **0-indexed** integer array `strength`, where `strength[i]` denotes the strength of the ith wizard. For a **contiguous** group of wizards (i.e. the wizards' strengths form a **subarray** of `strength`), the **total strength** is defined as the **product** of the following two values:
+
+* The strength of the **weakest** wizard in the group.
+* The **total** of all the individual strengths of the wizards in the group.
+
+Return _the **sum** of the total strengths of **all** contiguous groups of wizards_. Since the answer may be very large, return it **modulo** 109 + 7.
+
+A **subarray** is a contiguous **non-empty** sequence of elements within an array.
+
+**Example 1:**
+
+**Input:** strength = [1,3,1,2]
+
+**Output:** 44
+
+**Explanation:** The following are all the contiguous groups of wizards:
+
+- \[1] from [**1**,3,1,2] has a total strength of min([1]) \* sum([1]) = 1 \* 1 = 1
+
+- \[3] from [1,**3**,1,2] has a total strength of min([3]) \* sum([3]) = 3 \* 3 = 9
+
+- \[1] from [1,3,**1**,2] has a total strength of min([1]) \* sum([1]) = 1 \* 1 = 1
+
+- \[2] from [1,3,1,**2**] has a total strength of min([2]) \* sum([2]) = 2 \* 2 = 4
+
+- \[1,3] from [**1,3**,1,2] has a total strength of min([1,3]) \* sum([1,3]) = 1 \* 4 = 4
+
+- \[3,1] from [1,**3,1**,2] has a total strength of min([3,1]) \* sum([3,1]) = 1 \* 4 = 4
+
+- \[1,2] from [1,3,**1,2**] has a total strength of min([1,2]) \* sum([1,2]) = 1 \* 3 = 3
+
+- \[1,3,1] from [**1,3,1**,2] has a total strength of min([1,3,1]) \* sum([1,3,1]) = 1 \* 5 = 5
+
+- \[3,1,2] from [1,**3,1,2**] has a total strength of min([3,1,2]) \* sum([3,1,2]) = 1 \* 6 = 6
+
+- \[1,3,1,2] from [**1,3,1,2**] has a total strength of min([1,3,1,2]) \* sum([1,3,1,2]) = 1 \* 7 = 7
+
+The sum of all the total strengths is 1 + 9 + 1 + 4 + 4 + 4 + 3 + 5 + 6 + 7 = 44.
+
+**Example 2:**
+
+**Input:** strength = [5,4,6]
+
+**Output:** 213
+
+**Explanation:** The following are all the contiguous groups of wizards:
+
+- \[5] from [**5**,4,6] has a total strength of min([5]) \* sum([5]) = 5 \* 5 = 25
+
+- \[4] from [5,**4**,6] has a total strength of min([4]) \* sum([4]) = 4 \* 4 = 16
+
+- \[6] from [5,4,**6**] has a total strength of min([6]) \* sum([6]) = 6 \* 6 = 36
+
+- \[5,4] from [**5,4**,6] has a total strength of min([5,4]) \* sum([5,4]) = 4 \* 9 = 36
+
+- \[4,6] from [5,**4,6**] has a total strength of min([4,6]) \* sum([4,6]) = 4 \* 10 = 40
+
+- \[5,4,6] from [**5,4,6**] has a total strength of min([5,4,6]) \* sum([5,4,6]) = 4 \* 15 = 60
+
+The sum of all the total strengths is 25 + 16 + 36 + 36 + 40 + 60 = 213.
+
+**Constraints:**
+
+* 1 <= strength.length <= 105
+* 1 <= strength[i] <= 109
+
+## Solution
+
+```kotlin
+import java.util.Deque
+import java.util.LinkedList
+
+@Suppress("kotlin:S107")
+class Solution {
+ fun totalStrength(nums: IntArray): Int {
+ val n = nums.size
+ val forward = LongArray(n)
+ val backward = LongArray(n)
+ val prefix = LongArray(n + 1)
+ val suffix = LongArray(n + 1)
+ prefix[1] = nums[0].toLong()
+ forward[0] = prefix[1]
+ suffix[n - 1] = nums[n - 1].toLong()
+ backward[n - 1] = suffix[n - 1]
+ for (i in 1 until n) {
+ forward[i] = nums[i] + forward[i - 1]
+ prefix[i + 1] = prefix[i] + forward[i]
+ }
+ run {
+ var i = n - 2
+ while (0 <= i) {
+ backward[i] = nums[i] + backward[i + 1]
+ suffix[i] = suffix[i + 1] + backward[i]
+ --i
+ }
+ }
+ var res: Long = 0
+ val dq: Deque = LinkedList()
+ for (i in 0 until n) {
+ while (dq.isNotEmpty() && nums[dq.peekLast()] >= nums[i]) {
+ val cur = dq.pollLast()
+ val prev = if (dq.isEmpty()) -1 else dq.peekLast()
+ res = (
+ (
+ res +
+ getSum(
+ nums, forward, prefix, backward, suffix,
+ prev, cur, i
+ ) *
+ nums[cur]
+ ) %
+ mod
+ )
+ }
+ dq.add(i)
+ }
+ while (dq.isNotEmpty()) {
+ val cur = dq.pollLast()
+ val prev = if (dq.isEmpty()) -1 else dq.peekLast()
+ res = (
+ (
+ res +
+ getSum(nums, forward, prefix, backward, suffix, prev, cur, n) *
+ nums[cur]
+ ) %
+ mod
+ )
+ }
+ return res.toInt()
+ }
+
+ private fun getSum(
+ nums: IntArray,
+ forward: LongArray,
+ prefix: LongArray,
+ backward: LongArray,
+ suffix: LongArray,
+ prev: Int,
+ cur: Int,
+ next: Int
+ ): Long {
+ val sum = (cur - prev) * nums[cur].toLong() % mod * (next - cur) % mod
+ val preSum = getPresum(backward, suffix, prev + 1, cur - 1, next - cur)
+ val postSum = getPostsum(forward, prefix, cur + 1, next - 1, cur - prev)
+ return (sum + preSum + postSum) % mod
+ }
+
+ private fun getPresum(backward: LongArray, suffix: LongArray, from: Int, to: Int, m: Int): Long {
+ val n = backward.size
+ val cnt = to - from + 1L
+ return (
+ (suffix[from] - suffix[to + 1] - cnt * (if (to + 1 == n) 0 else backward[to + 1]) % mod) %
+ mod
+ * m %
+ mod
+ )
+ }
+
+ private fun getPostsum(forward: LongArray, prefix: LongArray, from: Int, to: Int, m: Int): Long {
+ val cnt = to - from + 1L
+ return (
+ (prefix[to + 1] - prefix[from] - cnt * (if (0 == from) 0 else forward[from - 1]) % mod) %
+ mod
+ * m %
+ mod
+ )
+ }
+
+ companion object {
+ private const val mod = 1e9.toInt() + 7
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2283_check_if_number_has_equal_digit_count_and_digit_value/readme.md b/src/main/kotlin/g2201_2300/s2283_check_if_number_has_equal_digit_count_and_digit_value/readme.md
new file mode 100644
index 00000000..6506caa2
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2283_check_if_number_has_equal_digit_count_and_digit_value/readme.md
@@ -0,0 +1,70 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2283\. Check if Number Has Equal Digit Count and Digit Value
+
+Easy
+
+You are given a **0-indexed** string `num` of length `n` consisting of digits.
+
+Return `true` _if for **every** index_ `i` _in the range_ `0 <= i < n`_, the digit_ `i` _occurs_ `num[i]` _times in_ `num`_, otherwise return_ `false`.
+
+**Example 1:**
+
+**Input:** num = "1210"
+
+**Output:** true
+
+**Explanation:**
+
+num[0] = '1'. The digit 0 occurs once in num.
+
+num[1] = '2'. The digit 1 occurs twice in num.
+
+num[2] = '1'. The digit 2 occurs once in num.
+
+num[3] = '0'. The digit 3 occurs zero times in num.
+
+The condition holds true for every index in "1210", so return true.
+
+**Example 2:**
+
+**Input:** num = "030"
+
+**Output:** false
+
+**Explanation:**
+
+num[0] = '0'. The digit 0 should occur zero times, but actually occurs twice in num.
+
+num[1] = '3'. The digit 1 should occur three times, but actually occurs zero times in num.
+
+num[2] = '0'. The digit 2 occurs zero times in num.
+
+The indices 0 and 1 both violate the condition, so return false.
+
+**Constraints:**
+
+* `n == num.length`
+* `1 <= n <= 10`
+* `num` consists of digits.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun digitCount(num: String): Boolean {
+ val cnt = IntArray(11)
+ val arr = num.toCharArray()
+ for (d in arr) {
+ ++cnt[d.code - '0'.code]
+ }
+ for (i in arr.indices) {
+ if (cnt[i] != arr[i].code - '0'.code) {
+ return false
+ }
+ }
+ return true
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2284_sender_with_largest_word_count/readme.md b/src/main/kotlin/g2201_2300/s2284_sender_with_largest_word_count/readme.md
new file mode 100644
index 00000000..aed6bcd6
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2284_sender_with_largest_word_count/readme.md
@@ -0,0 +1,83 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2284\. Sender With Largest Word Count
+
+Medium
+
+You have a chat log of `n` messages. You are given two string arrays `messages` and `senders` where `messages[i]` is a **message** sent by `senders[i]`.
+
+A **message** is list of **words** that are separated by a single space with no leading or trailing spaces. The **word count** of a sender is the total number of **words** sent by the sender. Note that a sender may send more than one message.
+
+Return _the sender with the **largest** word count_. If there is more than one sender with the largest word count, return _the one with the **lexicographically largest** name_.
+
+**Note:**
+
+* Uppercase letters come before lowercase letters in lexicographical order.
+* `"Alice"` and `"alice"` are distinct.
+
+**Example 1:**
+
+**Input:** messages = ["Hello userTwooo","Hi userThree","Wonderful day Alice","Nice day userThree"], senders = ["Alice","userTwo","userThree","Alice"]
+
+**Output:** "Alice"
+
+**Explanation:** Alice sends a total of 2 + 3 = 5 words.
+
+userTwo sends a total of 2 words.
+
+userThree sends a total of 3 words.
+
+Since Alice has the largest word count, we return "Alice".
+
+**Example 2:**
+
+**Input:** messages = ["How is leetcode for everyone","Leetcode is useful for practice"], senders = ["Bob","Charlie"]
+
+**Output:** "Charlie"
+
+**Explanation:** Bob sends a total of 5 words.
+
+Charlie sends a total of 5 words.
+
+Since there is a tie for the largest word count, we return the sender with the lexicographically larger name, Charlie.
+
+**Constraints:**
+
+* `n == messages.length == senders.length`
+* 1 <= n <= 104
+* `1 <= messages[i].length <= 100`
+* `1 <= senders[i].length <= 10`
+* `messages[i]` consists of uppercase and lowercase English letters and `' '`.
+* All the words in `messages[i]` are separated by **a single space**.
+* `messages[i]` does not have leading or trailing spaces.
+* `senders[i]` consists of uppercase and lowercase English letters only.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun largestWordCount(messages: Array, senders: Array): String {
+ val x = HashMap()
+ for (i in messages.indices) {
+ val words = messages[i].length - messages[i].replace(" ", "").length + 1
+ if (x.containsKey(senders[i])) {
+ x[senders[i]] = x[senders[i]]!! + words
+ } else {
+ x[senders[i]] = words
+ }
+ }
+ var result = ""
+ var max = 0
+ for ((key, value) in x) {
+ if (value > max ||
+ value == max && result.compareTo(key) < 0
+ ) {
+ max = value
+ result = key
+ }
+ }
+ return result
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2285_maximum_total_importance_of_roads/readme.md b/src/main/kotlin/g2201_2300/s2285_maximum_total_importance_of_roads/readme.md
new file mode 100644
index 00000000..c77de18d
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2285_maximum_total_importance_of_roads/readme.md
@@ -0,0 +1,104 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2285\. Maximum Total Importance of Roads
+
+Medium
+
+You are given an integer `n` denoting the number of cities in a country. The cities are numbered from `0` to `n - 1`.
+
+You are also given a 2D integer array `roads` where roads[i] = [ai, bi] denotes that there exists a **bidirectional** road connecting cities ai and bi.
+
+You need to assign each city with an integer value from `1` to `n`, where each value can only be used **once**. The **importance** of a road is then defined as the **sum** of the values of the two cities it connects.
+
+Return _the **maximum total importance** of all roads possible after assigning the values optimally._
+
+**Example 1:**
+
+
+
+**Input:** n = 5, roads = \[\[0,1],[1,2],[2,3],[0,2],[1,3],[2,4]]
+
+**Output:** 43
+
+**Explanation:** The figure above shows the country and the assigned values of [2,4,5,3,1].
+
+- The road (0,1) has an importance of 2 + 4 = 6.
+
+- The road (1,2) has an importance of 4 + 5 = 9.
+
+- The road (2,3) has an importance of 5 + 3 = 8.
+
+- The road (0,2) has an importance of 2 + 5 = 7.
+
+- The road (1,3) has an importance of 4 + 3 = 7.
+
+- The road (2,4) has an importance of 5 + 1 = 6.
+
+The total importance of all roads is 6 + 9 + 8 + 7 + 7 + 6 = 43.
+
+It can be shown that we cannot obtain a greater total importance than 43.
+
+**Example 2:**
+
+
+
+**Input:** n = 5, roads = \[\[0,3],[2,4],[1,3]]
+
+**Output:** 20
+
+**Explanation:** The figure above shows the country and the assigned values of [4,3,2,5,1].
+
+- The road (0,3) has an importance of 4 + 5 = 9.
+
+- The road (2,4) has an importance of 2 + 1 = 3.
+
+- The road (1,3) has an importance of 3 + 5 = 8.
+
+The total importance of all roads is 9 + 3 + 8 = 20.
+
+It can be shown that we cannot obtain a greater total importance than 20.
+
+**Constraints:**
+
+* 2 <= n <= 5 * 104
+* 1 <= roads.length <= 5 * 104
+* `roads[i].length == 2`
+* 0 <= ai, bi <= n - 1
+* ai != bi
+* There are no duplicate roads.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun maximumImportance(n: Int, roads: Array): Long {
+ val degree = IntArray(n)
+ var maxdegree = 0
+ for (r in roads) {
+ degree[r[0]]++
+ degree[r[1]]++
+ maxdegree = Math.max(maxdegree, Math.max(degree[r[0]], degree[r[1]]))
+ }
+ val rank: MutableMap = HashMap()
+ var i = n
+ while (i > 0) {
+ for (j in 0 until n) {
+ if (degree[j] == maxdegree) {
+ rank[j] = i--
+ degree[j] = Int.MIN_VALUE
+ }
+ }
+ maxdegree = 0
+ for (d in degree) {
+ maxdegree = Math.max(maxdegree, d)
+ }
+ }
+ var res: Long = 0
+ for (r in roads) {
+ res += (rank[r[0]]!! + rank[r[1]]!!).toLong()
+ }
+ return res
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2286_booking_concert_tickets_in_groups/readme.md b/src/main/kotlin/g2201_2300/s2286_booking_concert_tickets_in_groups/readme.md
new file mode 100644
index 00000000..9e08ef1a
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2286_booking_concert_tickets_in_groups/readme.md
@@ -0,0 +1,211 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2286\. Booking Concert Tickets in Groups
+
+Hard
+
+A concert hall has `n` rows numbered from `0` to `n - 1`, each with `m` seats, numbered from `0` to `m - 1`. You need to design a ticketing system that can allocate seats in the following cases:
+
+* If a group of `k` spectators can sit **together** in a row.
+* If **every** member of a group of `k` spectators can get a seat. They may or **may not** sit together.
+
+Note that the spectators are very picky. Hence:
+
+* They will book seats only if each member of their group can get a seat with row number **less than or equal** to `maxRow`. `maxRow` can **vary** from group to group.
+* In case there are multiple rows to choose from, the row with the **smallest** number is chosen. If there are multiple seats to choose in the same row, the seat with the **smallest** number is chosen.
+
+Implement the `BookMyShow` class:
+
+* `BookMyShow(int n, int m)` Initializes the object with `n` as number of rows and `m` as number of seats per row.
+* `int[] gather(int k, int maxRow)` Returns an array of length `2` denoting the row and seat number (respectively) of the **first seat** being allocated to the `k` members of the group, who must sit **together**. In other words, it returns the smallest possible `r` and `c` such that all `[c, c + k - 1]` seats are valid and empty in row `r`, and `r <= maxRow`. Returns `[]` in case it is **not possible** to allocate seats to the group.
+* `boolean scatter(int k, int maxRow)` Returns `true` if all `k` members of the group can be allocated seats in rows `0` to `maxRow`, who may or **may not** sit together. If the seats can be allocated, it allocates `k` seats to the group with the **smallest** row numbers, and the smallest possible seat numbers in each row. Otherwise, returns `false`.
+
+**Example 1:**
+
+**Input**
+
+["BookMyShow", "gather", "gather", "scatter", "scatter"]
+
+[[2, 5], [4, 0], [2, 0], [5, 1], [5, 1]]
+
+**Output:** [null, [0, 0], [], true, false]
+
+**Explanation:**
+
+ BookMyShow bms = new BookMyShow(2, 5); // There are 2 rows with 5 seats each
+ bms.gather(4, 0); // return [0, 0]
+ // The group books seats [0, 3] of row 0.
+ bms.gather(2, 0); // return []
+ // There is only 1 seat left in row 0,
+ // so it is not possible to book 2 consecutive seats.
+ bms.scatter(5, 1); // return True
+ // The group books seat 4 of row 0 and seats [0, 3] of row 1.
+ bms.scatter(5, 1); // return False
+ // There is only one seat left in the hall.
+
+**Constraints:**
+
+* 1 <= n <= 5 * 104
+* 1 <= m, k <= 109
+* `0 <= maxRow <= n - 1`
+* At most 5 * 104 calls **in total** will be made to `gather` and `scatter`.
+
+## Solution
+
+```kotlin
+import java.util.ArrayDeque
+import java.util.Arrays
+import java.util.Deque
+
+@Suppress("NAME_SHADOWING")
+class BookMyShow(n: Int, private val m: Int) {
+ private val n: Int
+
+ // max number of seats in a row for some segment of the rows
+ private val max: IntArray
+
+ // total number of seats for some segment of the rows
+ private val total: LongArray
+
+ // number of rows with zero free places on the left and on the right
+ // using this to quickly skip already zero rows
+ // actual nodes are placed in [1,this.n], the first and last element only shows there the first
+ // non-zero row
+ private val numZerosRight: IntArray
+ private val numZerosLeft: IntArray
+
+ init {
+ // make n to be a power of 2 (for simplicity)
+ this.n = nextPow2(n)
+ // segment tree for max number of seats in a row
+ max = IntArray(this.n * 2 - 1)
+ // total number of seats for a segment of the rows
+ total = LongArray(this.n * 2 - 1)
+ numZerosRight = IntArray(this.n + 2)
+ numZerosLeft = IntArray(this.n + 2)
+ // initialize max and total, for max we firstly set values to m
+ // segments of size 1 are placed starting from this.n - 1
+ Arrays.fill(max, this.n - 1, this.n + n - 1, m)
+ Arrays.fill(total, this.n - 1, this.n + n - 1, m.toLong())
+ // calculate values of max and total for segments based on values of their children
+ var i = this.n - 2
+ var i1 = i * 2 + 1
+ var i2 = i * 2 + 2
+ while (i >= 0) {
+ max[i] = Math.max(max[i1], max[i2])
+ total[i] = total[i1] + total[i2]
+ i--
+ i1 -= 2
+ i2 -= 2
+ }
+ }
+
+ fun gather(k: Int, maxRow: Int): IntArray {
+ // find most left row with enough free places
+ val mostLeft = mostLeft(0, 0, n, k, maxRow + 1)
+ if (mostLeft == -1) {
+ return IntArray(0)
+ }
+ // get corresponding segment tree node
+ var v = n - 1 + mostLeft
+ val ans = intArrayOf(mostLeft, m - max[v])
+ // update max and total for this node
+ max[v] -= k
+ total[v] -= k.toLong()
+ // until this is a root of segment tree we update its parent
+ while (v != 0) {
+ v = (v - 1) / 2
+ max[v] = Math.max(max[v * 2 + 1], max[v * 2 + 2])
+ total[v] = total[v * 2 + 1] + total[v * 2 + 2]
+ }
+ return ans
+ }
+
+ private fun mostLeft(v: Int, l: Int, r: Int, k: Int, qr: Int): Int {
+ if (l >= qr || max[v] < k) {
+ return -1
+ }
+ if (l == r - 1) {
+ return l
+ }
+ val mid = (l + r) / 2
+ val left = mostLeft(v * 2 + 1, l, mid, k, qr)
+ return if (left != -1) {
+ left
+ } else mostLeft(v * 2 + 2, mid, r, k, qr)
+ }
+
+ fun scatter(k: Int, maxRow: Int): Boolean {
+ // find total number of free places in the rows [0; maxRow+1)
+ var k = k
+ val sum = total(0, 0, n, maxRow + 1)
+ if (sum < k) {
+ return false
+ }
+ var i = 0
+ // to don't update parent for both of its children we use a queue
+ val deque: Deque = ArrayDeque()
+ while (k != 0) {
+ i += numZerosRight[i] + 1
+ var v = n - 1 + i - 1
+ val spent = Math.min(k, max[v])
+ k -= spent
+ max[v] -= spent
+ total[v] -= spent.toLong()
+ if (max[v] == 0) {
+ // update numZerosRight and numZerosLeft
+ numZerosRight[i - numZerosLeft[i] - 1] += numZerosRight[i] + 1
+ numZerosLeft[i + numZerosRight[i] + 1] += numZerosLeft[i] + 1
+ }
+ if (v != 0) {
+ v = (v - 1) / 2
+ // if we already have the parent node in the queue we don't need to update it
+ if (deque.isEmpty() || deque.peekLast() != v) {
+ deque.addLast(v)
+ }
+ }
+ }
+ // update max and total
+ while (deque.isNotEmpty()) {
+ var v = deque.pollFirst()
+ max[v] = Math.max(max[v * 2 + 1], max[v * 2 + 2])
+ total[v] = total[v * 2 + 1] + total[v * 2 + 2]
+ if (v != 0) {
+ v = (v - 1) / 2
+ // if we already have the parent node in the queue we don't need to update it
+ if (deque.isEmpty() || deque.peekLast() != v) {
+ deque.addLast(v)
+ }
+ }
+ }
+ return true
+ }
+
+ // find sum of [ql, qr)
+ private fun total(v: Int, l: Int, r: Int, qr: Int): Long {
+ if (l >= qr) {
+ return 0
+ }
+ if (r <= qr) {
+ return total[v]
+ }
+ val mid = (l + r) / 2
+ return total(v * 2 + 1, l, mid, qr) + total(v * 2 + 2, mid, r, qr)
+ }
+
+ companion object {
+ private fun nextPow2(n: Int): Int {
+ return if (n and n - 1 == 0) {
+ n
+ } else Integer.highestOneBit(n) shl 1
+ }
+ }
+}
+/*
+ * Your BookMyShow object will be instantiated and called as such:
+ * var obj = BookMyShow(n, m)
+ * var param_1 = obj.gather(k,maxRow)
+ * var param_2 = obj.scatter(k,maxRow)
+ */
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2287_rearrange_characters_to_make_target_string/readme.md b/src/main/kotlin/g2201_2300/s2287_rearrange_characters_to_make_target_string/readme.md
new file mode 100644
index 00000000..bffaef79
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2287_rearrange_characters_to_make_target_string/readme.md
@@ -0,0 +1,85 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2287\. Rearrange Characters to Make Target String
+
+Easy
+
+You are given two **0-indexed** strings `s` and `target`. You can take some letters from `s` and rearrange them to form new strings.
+
+Return _the **maximum** number of copies of_ `target` _that can be formed by taking letters from_ `s` _and rearranging them._
+
+**Example 1:**
+
+**Input:** s = "ilovecodingonleetcode", target = "code"
+
+**Output:** 2
+
+**Explanation:**
+
+For the first copy of "code", take the letters at indices 4, 5, 6, and 7.
+
+For the second copy of "code", take the letters at indices 17, 18, 19, and 20.
+
+The strings that are formed are "ecod" and "code" which can both be rearranged into "code".
+
+We can make at most two copies of "code", so we return 2.
+
+**Example 2:**
+
+**Input:** s = "abcba", target = "abc"
+
+**Output:** 1
+
+**Explanation:**
+
+We can make one copy of "abc" by taking the letters at indices 0, 1, and 2.
+
+We can make at most one copy of "abc", so we return 1.
+
+Note that while there is an extra 'a' and 'b' at indices 3 and 4, we cannot reuse the letter 'c' at index 2, so we cannot make a second copy of "abc".
+
+**Example 3:**
+
+**Input:** s = "abbaccaddaeea", target = "aaaaa"
+
+**Output:** 1
+
+**Explanation:**
+
+We can make one copy of "aaaaa" by taking the letters at indices 0, 3, 6, 9, and 12.
+
+We can make at most one copy of "aaaaa", so we return 1.
+
+**Constraints:**
+
+* `1 <= s.length <= 100`
+* `1 <= target.length <= 10`
+* `s` and `target` consist of lowercase English letters.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun rearrangeCharacters(s: String, target: String): Int {
+ return getMaxCopies(target, getCharCount(s), getCharCount(target))
+ }
+
+ private fun getCharCount(str: String): IntArray {
+ val charToCount = IntArray(26)
+ for (i in 0 until str.length) {
+ charToCount[str[i].code - 'a'.code]++
+ }
+ return charToCount
+ }
+
+ private fun getMaxCopies(target: String, sCount: IntArray, tCount: IntArray): Int {
+ var copies = Int.MAX_VALUE
+ for (i in 0 until target.length) {
+ val ch = target[i].code - 'a'.code
+ copies = Math.min(copies, sCount[ch] / tCount[ch])
+ }
+ return copies
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2288_apply_discount_to_prices/readme.md b/src/main/kotlin/g2201_2300/s2288_apply_discount_to_prices/readme.md
new file mode 100644
index 00000000..740856de
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2288_apply_discount_to_prices/readme.md
@@ -0,0 +1,98 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2288\. Apply Discount to Prices
+
+Medium
+
+A **sentence** is a string of single-space separated words where each word can contain digits, lowercase letters, and the dollar sign `'$'`. A word represents a **price** if it is a sequence of digits preceded by a dollar sign.
+
+* For example, `"$100"`, `"$23"`, and `"$6"` represent prices while `"100"`, `"$"`, and `"$1e5"` do not.
+
+You are given a string `sentence` representing a sentence and an integer `discount`. For each word representing a price, apply a discount of `discount%` on the price and **update** the word in the sentence. All updated prices should be represented with **exactly two** decimal places.
+
+Return _a string representing the modified sentence_.
+
+Note that all prices will contain **at most** `10` digits.
+
+**Example 1:**
+
+**Input:** sentence = "there are $1 $2 and 5$ candies in the shop", discount = 50
+
+**Output:** "there are $0.50 $1.00 and 5$ candies in the shop"
+
+**Explanation:**
+
+The words which represent prices are "$1" and "$2".
+
+- A 50% discount on "$1" yields "$0.50", so "$1" is replaced by "$0.50".
+
+- A 50% discount on "$2" yields "$1". Since we need to have exactly 2 decimal places after a price, we replace "$2" with "$1.00".
+
+**Example 2:**
+
+**Input:** sentence = "1 2 $3 4 $5 $6 7 8$ $9 $10$", discount = 100
+
+**Output:** "1 2 $0.00 4 $0.00 $0.00 7 8$ $0.00 $10$"
+
+**Explanation:**
+
+Applying a 100% discount on any price will result in 0.
+
+The words representing prices are "$3", "$5", "$6", and "$9".
+
+Each of them is replaced by "$0.00".
+
+**Constraints:**
+
+* 1 <= sentence.length <= 105
+* `sentence` consists of lowercase English letters, digits, `' '`, and `'$'`.
+* `sentence` does not have leading or trailing spaces.
+* All words in `sentence` are separated by a single space.
+* All prices will be **positive** numbers without leading zeros.
+* All prices will have **at most** `10` digits.
+* `0 <= discount <= 100`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun discountPrices(sentence: String, discount: Int): String {
+ val words = sentence.split(" ").dropLastWhile { it.isEmpty() }.toTypedArray()
+ val sb = StringBuilder()
+ for (word in words) {
+ sb.append(applyDiscount(word, discount))
+ sb.append(" ")
+ }
+ sb.deleteCharAt(sb.length - 1)
+ return sb.toString()
+ }
+
+ private fun applyDiscount(s: String, discount: Int): String {
+ if (s[0] == '$' && s.length > 1) {
+ var price: Long = 0
+ for (i in 1 until s.length) {
+ if (!Character.isDigit(s[i])) {
+ // Error case. We could also use Long.parseLong() here.
+ return s
+ }
+ price *= 10
+ price += ((s[i].code - '0'.code) * (100 - discount)).toLong()
+ }
+ val stringPrice = price.toString()
+ if (price < 10) {
+ return "$0.0$stringPrice"
+ }
+ return if (price < 100) {
+ "$0.$stringPrice"
+ } else (
+ "$" +
+ stringPrice.substring(0, stringPrice.length - 2) +
+ "." +
+ stringPrice.substring(stringPrice.length - 2)
+ )
+ }
+ return s
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2289_steps_to_make_array_non_decreasing/readme.md b/src/main/kotlin/g2201_2300/s2289_steps_to_make_array_non_decreasing/readme.md
new file mode 100644
index 00000000..cafc24ce
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2289_steps_to_make_array_non_decreasing/readme.md
@@ -0,0 +1,64 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2289\. Steps to Make Array Non-decreasing
+
+Medium
+
+You are given a **0-indexed** integer array `nums`. In one step, **remove** all elements `nums[i]` where `nums[i - 1] > nums[i]` for all `0 < i < nums.length`.
+
+Return _the number of steps performed until_ `nums` _becomes a **non-decreasing** array_.
+
+**Example 1:**
+
+**Input:** nums = [5,3,4,4,7,3,6,11,8,5,11]
+
+**Output:** 3
+
+**Explanation:** The following are the steps performed:
+
+- Step 1: [5,**3**,4,4,7,**3**,6,11,**8**,**5**,11] becomes [5,4,4,7,6,11,11]
+
+- Step 2: [5,**4**,4,7,**6**,11,11] becomes [5,4,7,11,11]
+
+- Step 3: [5,**4**,7,11,11] becomes [5,7,11,11]
+
+[5,7,11,11] is a non-decreasing array. Therefore, we return 3.
+
+**Example 2:**
+
+**Input:** nums = [4,5,7,7,13]
+
+**Output:** 0
+
+**Explanation:** nums is already a non-decreasing array. Therefore, we return 0.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* 1 <= nums[i] <= 109
+
+## Solution
+
+```kotlin
+class Solution {
+ fun totalSteps(nums: IntArray): Int {
+ var max = 0
+ val pos = IntArray(nums.size + 1)
+ val steps = IntArray(nums.size + 1)
+ var top = -1
+ for (i in 0..nums.size) {
+ val `val` = if (i == nums.size) Int.MAX_VALUE else nums[i]
+ while (top >= 0 && nums[pos[top]] <= `val`) {
+ if (top == 0) {
+ max = Math.max(max, steps[pos[top--]])
+ } else {
+ steps[pos[--top]] = Math.max(steps[pos[top]] + 1, steps[pos[top + 1]])
+ }
+ }
+ pos[++top] = i
+ }
+ return max
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2290_minimum_obstacle_removal_to_reach_corner/readme.md b/src/main/kotlin/g2201_2300/s2290_minimum_obstacle_removal_to_reach_corner/readme.md
new file mode 100644
index 00000000..b16dd0df
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2290_minimum_obstacle_removal_to_reach_corner/readme.md
@@ -0,0 +1,89 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2290\. Minimum Obstacle Removal to Reach Corner
+
+Hard
+
+You are given a **0-indexed** 2D integer array `grid` of size `m x n`. Each cell has one of two values:
+
+* `0` represents an **empty** cell,
+* `1` represents an **obstacle** that may be removed.
+
+You can move up, down, left, or right from and to an empty cell.
+
+Return _the **minimum** number of **obstacles** to **remove** so you can move from the upper left corner_ `(0, 0)` _to the lower right corner_ `(m - 1, n - 1)`.
+
+**Example 1:**
+
+
+
+**Input:** grid = \[\[0,1,1],[1,1,0],[1,1,0]]
+
+**Output:** 2
+
+**Explanation:** We can remove the obstacles at (0, 1) and (0, 2) to create a path from (0, 0) to (2, 2).
+
+It can be shown that we need to remove at least 2 obstacles, so we return 2.
+
+Note that there may be other ways to remove 2 obstacles to create a path.
+
+**Example 2:**
+
+
+
+**Input:** grid = \[\[0,1,0,0,0],[0,1,0,1,0],[0,0,0,1,0]]
+
+**Output:** 0
+
+**Explanation:** We can move from (0, 0) to (2, 4) without removing any obstacles, so we return 0.
+
+**Constraints:**
+
+* `m == grid.length`
+* `n == grid[i].length`
+* 1 <= m, n <= 105
+* 2 <= m * n <= 105
+* `grid[i][j]` is either `0` **or** `1`.
+* `grid[0][0] == grid[m - 1][n - 1] == 0`
+
+## Solution
+
+```kotlin
+import java.util.PriorityQueue
+import java.util.Queue
+
+class Solution {
+ fun minimumObstacles(grid: Array): Int {
+ val n = grid.size
+ val m = grid[0].size
+ val dirs = arrayOf(intArrayOf(0, 1), intArrayOf(1, 0), intArrayOf(0, -1), intArrayOf(-1, 0))
+ val q: Queue = PriorityQueue { a: State, b: State -> a.removed - b.removed }
+ q.add(State(0, 0, 0))
+ val visited = Array(n) { BooleanArray(m) }
+ visited[0][0] = true
+ while (q.isNotEmpty()) {
+ val state = q.poll()
+ if (state.r == n - 1 && state.c == m - 1) {
+ return state.removed
+ }
+ for (d in dirs) {
+ val nr = state.r + d[0]
+ val nc = state.c + d[1]
+ if (nr < 0 || nc < 0 || nr == n || nc == m || visited[nr][nc]) {
+ continue
+ }
+ visited[nr][nc] = true
+ val next = State(nr, nc, state.removed)
+ if (grid[nr][nc] == 1) {
+ next.removed++
+ }
+ q.add(next)
+ }
+ }
+ return -1
+ }
+
+ private class State(var r: Int, var c: Int, var removed: Int)
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2293_min_max_game/readme.md b/src/main/kotlin/g2201_2300/s2293_min_max_game/readme.md
new file mode 100644
index 00000000..3e98a9a8
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2293_min_max_game/readme.md
@@ -0,0 +1,72 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2293\. Min Max Game
+
+Easy
+
+You are given a **0-indexed** integer array `nums` whose length is a power of `2`.
+
+Apply the following algorithm on `nums`:
+
+1. Let `n` be the length of `nums`. If `n == 1`, **end** the process. Otherwise, **create** a new **0-indexed** integer array `newNums` of length `n / 2`.
+2. For every **even** index `i` where `0 <= i < n / 2`, **assign** the value of `newNums[i]` as `min(nums[2 * i], nums[2 * i + 1])`.
+3. For every **odd** index `i` where `0 <= i < n / 2`, **assign** the value of `newNums[i]` as `max(nums[2 * i], nums[2 * i + 1])`.
+4. **Replace** the array `nums` with `newNums`.
+5. **Repeat** the entire process starting from step 1.
+
+Return _the last number that remains in_ `nums` _after applying the algorithm._
+
+**Example 1:**
+
+
+
+**Input:** nums = [1,3,5,2,4,8,2,2]
+
+**Output:** 1
+
+**Explanation:** The following arrays are the results of applying the algorithm repeatedly.
+
+First: nums = [1,5,4,2]
+
+Second: nums = [1,4]
+
+Third: nums = [1]
+
+1 is the last remaining number, so we return 1.
+
+**Example 2:**
+
+**Input:** nums = [3]
+
+**Output:** 3
+
+**Explanation:** 3 is already the last remaining number, so we return 3.
+
+**Constraints:**
+
+* `1 <= nums.length <= 1024`
+* 1 <= nums[i] <= 109
+* `nums.length` is a power of `2`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minMaxGame(nums: IntArray): Int {
+ val n = nums.size
+ if (n == 1) {
+ return nums[0]
+ }
+ val newNums = IntArray(n / 2)
+ for (i in 0 until n / 2) {
+ if (i % 2 == 0) {
+ newNums[i] = Math.min(nums[2 * i], nums[2 * i + 1])
+ } else {
+ newNums[i] = Math.max(nums[2 * i], nums[2 * i + 1])
+ }
+ }
+ return minMaxGame(newNums)
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2294_partition_array_such_that_maximum_difference_is_k/readme.md b/src/main/kotlin/g2201_2300/s2294_partition_array_such_that_maximum_difference_is_k/readme.md
new file mode 100644
index 00000000..e9a3f4a9
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2294_partition_array_such_that_maximum_difference_is_k/readme.md
@@ -0,0 +1,87 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2294\. Partition Array Such That Maximum Difference Is K
+
+Medium
+
+You are given an integer array `nums` and an integer `k`. You may partition `nums` into one or more **subsequences** such that each element in `nums` appears in **exactly** one of the subsequences.
+
+Return _the **minimum** number of subsequences needed such that the difference between the maximum and minimum values in each subsequence is **at most**_ `k`_._
+
+A **subsequence** is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.
+
+**Example 1:**
+
+**Input:** nums = [3,6,1,2,5], k = 2
+
+**Output:** 2
+
+**Explanation:**
+
+We can partition nums into the two subsequences [3,1,2] and [6,5].
+
+The difference between the maximum and minimum value in the first subsequence is 3 - 1 = 2.
+
+The difference between the maximum and minimum value in the second subsequence is 6 - 5 = 1.
+
+Since two subsequences were created, we return 2. It can be shown that 2 is the minimum number of subsequences needed.
+
+**Example 2:**
+
+**Input:** nums = [1,2,3], k = 1
+
+**Output:** 2
+
+**Explanation:**
+
+We can partition nums into the two subsequences [1,2] and [3].
+
+The difference between the maximum and minimum value in the first subsequence is 2 - 1 = 1.
+
+The difference between the maximum and minimum value in the second subsequence is 3 - 3 = 0.
+
+Since two subsequences were created, we return 2. Note that another optimal solution is to partition nums into the two subsequences [1] and [2,3].
+
+**Example 3:**
+
+**Input:** nums = [2,2,4,5], k = 0
+
+**Output:** 3
+
+**Explanation:**
+
+We can partition nums into the three subsequences [2,2], [4], and [5].
+
+The difference between the maximum and minimum value in the first subsequences is 2 - 2 = 0.
+
+The difference between the maximum and minimum value in the second subsequences is 4 - 4 = 0.
+
+The difference between the maximum and minimum value in the third subsequences is 5 - 5 = 0.
+
+Since three subsequences were created, we return 3. It can be shown that 3 is the minimum number of subsequences needed.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* 0 <= nums[i] <= 105
+* 0 <= k <= 105
+
+## Solution
+
+```kotlin
+class Solution {
+ fun partitionArray(nums: IntArray, k: Int): Int {
+ nums.sort()
+ var partitions = 1
+ var j = 0
+ for (i in 1 until nums.size) {
+ if (nums[i] - nums[j] > k) {
+ partitions++
+ j = i
+ }
+ }
+ return partitions
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2295_replace_elements_in_an_array/readme.md b/src/main/kotlin/g2201_2300/s2295_replace_elements_in_an_array/readme.md
new file mode 100644
index 00000000..bfddc57f
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2295_replace_elements_in_an_array/readme.md
@@ -0,0 +1,81 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2295\. Replace Elements in an Array
+
+Medium
+
+You are given a **0-indexed** array `nums` that consists of `n` **distinct** positive integers. Apply `m` operations to this array, where in the ith operation you replace the number `operations[i][0]` with `operations[i][1]`.
+
+It is guaranteed that in the ith operation:
+
+* `operations[i][0]` **exists** in `nums`.
+* `operations[i][1]` does **not** exist in `nums`.
+
+Return _the array obtained after applying all the operations_.
+
+**Example 1:**
+
+**Input:** nums = [1,2,4,6], operations = \[\[1,3],[4,7],[6,1]]
+
+**Output:** [3,2,7,1]
+
+**Explanation:**
+
+We perform the following operations on nums:
+
+- Replace the number 1 with 3. nums becomes [**3**,2,4,6].
+
+- Replace the number 4 with 7. nums becomes [3,2,**7**,6].
+
+- Replace the number 6 with 1. nums becomes [3,2,7,**1**].
+
+We return the final array [3,2,7,1].
+
+**Example 2:**
+
+**Input:** nums = [1,2], operations = \[\[1,3],[2,1],[3,2]]
+
+**Output:** [2,1]
+
+**Explanation:**
+
+We perform the following operations to nums:
+
+- Replace the number 1 with 3. nums becomes [**3**,2].
+
+- Replace the number 2 with 1. nums becomes [3,**1**].
+
+- Replace the number 3 with 2. nums becomes [**2**,1].
+
+We return the array [2,1].
+
+**Constraints:**
+
+* `n == nums.length`
+* `m == operations.length`
+* 1 <= n, m <= 105
+* All the values of `nums` are **distinct**.
+* `operations[i].length == 2`
+* 1 <= nums[i], operations[i][0], operations[i][1] <= 106
+* `operations[i][0]` will exist in `nums` when applying the ith operation.
+* `operations[i][1]` will not exist in `nums` when applying the ith operation.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun arrayChange(nums: IntArray, operations: Array): IntArray {
+ val map = HashMap()
+ for (i in nums.indices) {
+ map[nums[i]] = i
+ }
+ for (operation in operations) {
+ val index = map[operation[0]]!!
+ nums[index] = operation[1]
+ map[operation[1]] = index
+ }
+ return nums
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2296_design_a_text_editor/readme.md b/src/main/kotlin/g2201_2300/s2296_design_a_text_editor/readme.md
new file mode 100644
index 00000000..d7a22cd7
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2296_design_a_text_editor/readme.md
@@ -0,0 +1,106 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2296\. Design a Text Editor
+
+Hard
+
+Design a text editor with a cursor that can do the following:
+
+* **Add** text to where the cursor is.
+* **Delete** text from where the cursor is (simulating the backspace key).
+* **Move** the cursor either left or right.
+
+When deleting text, only characters to the left of the cursor will be deleted. The cursor will also remain within the actual text and cannot be moved beyond it. More formally, we have that `0 <= cursor.position <= currentText.length` always holds.
+
+Implement the `TextEditor` class:
+
+* `TextEditor()` Initializes the object with empty text.
+* `void addText(string text)` Appends `text` to where the cursor is. The cursor ends to the right of `text`.
+* `int deleteText(int k)` Deletes `k` characters to the left of the cursor. Returns the number of characters actually deleted.
+* `string cursorLeft(int k)` Moves the cursor to the left `k` times. Returns the last `min(10, len)` characters to the left of the cursor, where `len` is the number of characters to the left of the cursor.
+* `string cursorRight(int k)` Moves the cursor to the right `k` times. Returns the last `min(10, len)` characters to the left of the cursor, where `len` is the number of characters to the left of the cursor.
+
+**Example 1:**
+
+**Input** ["TextEditor", "addText", "deleteText", "addText", "cursorRight", "cursorLeft", "deleteText", "cursorLeft", "cursorRight"] [[], ["leetcode"], [4], ["practice"], [3], [8], [10], [2], [6]]
+
+**Output:** [null, null, 4, null, "etpractice", "leet", 4, "", "practi"]
+
+**Explanation:**
+
+ TextEditor textEditor = new TextEditor(); // The current text is "|". (The '|' character represents the cursor)
+ textEditor.addText("leetcode"); // The current text is "leetcode|".
+ textEditor.deleteText(4); // return 4
+ // The current text is "leet|".
+ // 4 characters were deleted.
+ textEditor.addText("practice"); // The current text is "leetpractice|".
+ textEditor.cursorRight(3); // return "etpractice"
+ // The current text is "leetpractice|".
+ // The cursor cannot be moved beyond the actual text and thus did not move.
+ // "etpractice" is the last 10 characters to the left of the cursor.
+ textEditor.cursorLeft(8); // return "leet"
+ // The current text is "leet|practice".
+ // "leet" is the last min(10, 4) = 4 characters to the left of the cursor.
+ textEditor.deleteText(10); // return 4
+ // The current text is "|practice".
+ // Only 4 characters were deleted.
+ textEditor.cursorLeft(2); // return ""
+ // The current text is "|practice".
+ // The cursor cannot be moved beyond the actual text and thus did not move.
+ // "" is the last min(10, 0) = 0 characters to the left of the cursor.
+ textEditor.cursorRight(6); // return "practi"
+ // The current text is "practi|ce".
+ // "practi" is the last min(10, 6) = 6 characters to the left of the cursor.
+
+**Constraints:**
+
+* `1 <= text.length, k <= 40`
+* `text` consists of lowercase English letters.
+* At most 2 * 104 calls **in total** will be made to `addText`, `deleteText`, `cursorLeft` and `cursorRight`.
+
+**Follow-up:** Could you find a solution with time complexity of `O(k)` per call?
+
+## Solution
+
+```kotlin
+class TextEditor {
+ private val sb: StringBuilder = StringBuilder()
+ private var cursor = 0
+
+ fun addText(text: String) {
+ sb.insert(cursor, text)
+ cursor += text.length
+ }
+
+ fun deleteText(k: Int): Int {
+ val prevPos = cursor
+ if (cursor - k >= 0) {
+ cursor -= k
+ sb.delete(cursor, cursor + k)
+ } else {
+ sb.delete(0, cursor)
+ cursor = 0
+ }
+ return prevPos - cursor
+ }
+
+ fun cursorLeft(k: Int): String {
+ cursor = Math.max(cursor - k, 0)
+ return sb.substring(Math.max(cursor - 10, 0), cursor)
+ }
+
+ fun cursorRight(k: Int): String {
+ cursor = Math.min(cursor + k, sb.length)
+ return sb.substring(Math.max(cursor - 10, 0), cursor)
+ }
+}
+/*
+ * Your TextEditor object will be instantiated and called as such:
+ * var obj = TextEditor()
+ * obj.addText(text)
+ * var param_2 = obj.deleteText(k)
+ * var param_3 = obj.cursorLeft(k)
+ * var param_4 = obj.cursorRight(k)
+ */
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2299_strong_password_checker_ii/readme.md b/src/main/kotlin/g2201_2300/s2299_strong_password_checker_ii/readme.md
new file mode 100644
index 00000000..3e262f56
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2299_strong_password_checker_ii/readme.md
@@ -0,0 +1,81 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2299\. Strong Password Checker II
+
+Easy
+
+A password is said to be **strong** if it satisfies all the following criteria:
+
+* It has at least `8` characters.
+* It contains at least **one lowercase** letter.
+* It contains at least **one uppercase** letter.
+* It contains at least **one digit**.
+* It contains at least **one special character**. The special characters are the characters in the following string: `"!@#$%^&*()-+"`.
+* It does **not** contain `2` of the same character in adjacent positions (i.e., `"aab"` violates this condition, but `"aba"` does not).
+
+Given a string `password`, return `true` _if it is a **strong** password_. Otherwise, return `false`.
+
+**Example 1:**
+
+**Input:** password = "IloveLe3tcode!"
+
+**Output:** true
+
+**Explanation:** The password meets all the requirements. Therefore, we return true.
+
+**Example 2:**
+
+**Input:** password = "Me+You--IsMyDream"
+
+**Output:** false
+
+**Explanation:** The password does not contain a digit and also contains 2 of the same character in adjacent positions. Therefore, we return false.
+
+**Example 3:**
+
+**Input:** password = "1aB!"
+
+**Output:** false
+
+**Explanation:** The password does not meet the length requirement. Therefore, we return false.
+
+**Constraints:**
+
+* `1 <= password.length <= 100`
+* `password` consists of letters, digits, and special characters: `"!@#$%^&*()-+"`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun strongPasswordCheckerII(password: String): Boolean {
+ if (password.length < 8) {
+ return false
+ }
+ var l = false
+ var u = false
+ var d = false
+ var s = false
+ val special = "!@#$%^&*()-+"
+ var previous = '.'
+ for (i in 0 until password.length) {
+ val ch = password[i]
+ if (ch == previous) {
+ return false
+ }
+ previous = ch
+ if (ch >= 'A' && ch <= 'Z') {
+ u = true
+ } else if (ch >= 'a' && ch <= 'z') {
+ l = true
+ } else if (ch >= '0' && ch <= '9') {
+ d = true
+ } else if (special.indexOf(ch) != -1) {
+ s = true
+ }
+ }
+ return l && u && d && s
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2201_2300/s2300_successful_pairs_of_spells_and_potions/readme.md b/src/main/kotlin/g2201_2300/s2300_successful_pairs_of_spells_and_potions/readme.md
new file mode 100644
index 00000000..3a45435c
--- /dev/null
+++ b/src/main/kotlin/g2201_2300/s2300_successful_pairs_of_spells_and_potions/readme.md
@@ -0,0 +1,76 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2300\. Successful Pairs of Spells and Potions
+
+Medium
+
+You are given two positive integer arrays `spells` and `potions`, of length `n` and `m` respectively, where `spells[i]` represents the strength of the ith spell and `potions[j]` represents the strength of the jth potion.
+
+You are also given an integer `success`. A spell and potion pair is considered **successful** if the **product** of their strengths is **at least** `success`.
+
+Return _an integer array_ `pairs` _of length_ `n` _where_ `pairs[i]` _is the number of **potions** that will form a successful pair with the_ ith _spell._
+
+**Example 1:**
+
+**Input:** spells = [5,1,3], potions = [1,2,3,4,5], success = 7
+
+**Output:** [4,0,3]
+
+**Explanation:**
+
+- 0th spell: 5 \* [1,2,3,4,5] = [5,**10**,**15**,**20**,**25**]. 4 pairs are successful.
+
+- 1st spell: 1 \* [1,2,3,4,5] = [1,2,3,4,5]. 0 pairs are successful.
+
+- 2nd spell: 3 \* [1,2,3,4,5] = [3,6,**9**,**12**,**15**]. 3 pairs are successful.
+
+Thus, [4,0,3] is returned.
+
+**Example 2:**
+
+**Input:** spells = [3,1,2], potions = [8,5,8], success = 16
+
+**Output:** [2,0,2]
+
+**Explanation:**
+
+- 0th spell: 3 \* [8,5,8] = [**24**,15,**24**]. 2 pairs are successful.
+
+- 1st spell: 1 \* [8,5,8] = [8,5,8]. 0 pairs are successful.
+
+- 2nd spell: 2 \* [8,5,8] = [**16**,10,**16**]. 2 pairs are successful.
+
+Thus, [2,0,2] is returned.
+
+**Constraints:**
+
+* `n == spells.length`
+* `m == potions.length`
+* 1 <= n, m <= 105
+* 1 <= spells[i], potions[i] <= 105
+* 1 <= success <= 1010
+
+## Solution
+
+```kotlin
+class Solution {
+ fun successfulPairs(spells: IntArray, potions: IntArray, success: Long): IntArray {
+ potions.sort()
+ for (i in spells.indices) {
+ var l = 0
+ var r = potions.size
+ while (l < r) {
+ val m = l + (r - l) / 2
+ if (spells[i].toLong() * potions[m] >= success) {
+ r = m
+ } else {
+ l = m + 1
+ }
+ }
+ spells[i] = potions.size - l
+ }
+ return spells
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2301_2400/s2301_match_substring_after_replacement/readme.md b/src/main/kotlin/g2301_2400/s2301_match_substring_after_replacement/readme.md
new file mode 100644
index 00000000..30e1e20e
--- /dev/null
+++ b/src/main/kotlin/g2301_2400/s2301_match_substring_after_replacement/readme.md
@@ -0,0 +1,96 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2301\. Match Substring After Replacement
+
+Hard
+
+You are given two strings `s` and `sub`. You are also given a 2D character array `mappings` where mappings[i] = [oldi, newi] indicates that you may **replace** any number of oldi characters of `sub` with newi. Each character in `sub` **cannot** be replaced more than once.
+
+Return `true` _if it is possible to make_ `sub` _a substring of_ `s` _by replacing zero or more characters according to_ `mappings`. Otherwise, return `false`.
+
+A **substring** is a contiguous non-empty sequence of characters within a string.
+
+**Example 1:**
+
+**Input:** s = "fool3e7bar", sub = "leet", mappings = \[\["e","3"],["t","7"],["t","8"]]
+
+**Output:** true
+
+**Explanation:** Replace the first 'e' in sub with '3' and 't' in sub with '7'.
+
+Now sub = "l3e7" is a substring of s, so we return true.
+
+**Example 2:**
+
+**Input:** s = "fooleetbar", sub = "f00l", mappings = \[\["o","0"]]
+
+**Output:** false
+
+**Explanation:** The string "f00l" is not a substring of s and no replacements can be made.
+
+Note that we cannot replace '0' with 'o'.
+
+**Example 3:**
+
+**Input:** s = "Fool33tbaR", sub = "leetd", mappings = \[\["e","3"],["t","7"],["t","8"],["d","b"],["p","b"]]
+
+**Output:** true
+
+**Explanation:** Replace the first and second 'e' in sub with '3' and 'd' in sub with 'b'.
+
+Now sub = "l33tb" is a substring of s, so we return true.
+
+**Constraints:**
+
+* `1 <= sub.length <= s.length <= 5000`
+* `0 <= mappings.length <= 1000`
+* `mappings[i].length == 2`
+* oldi != newi
+* `s` and `sub` consist of uppercase and lowercase English letters and digits.
+* oldi and newi are either uppercase or lowercase English letters or digits.
+
+## Solution
+
+```kotlin
+@Suppress("NAME_SHADOWING")
+class Solution {
+ private lateinit var c1: CharArray
+ private lateinit var c2: CharArray
+ private lateinit var al: Array?>
+ fun matchReplacement(s: String, sub: String, mappings: Array): Boolean {
+ c1 = s.toCharArray()
+ c2 = sub.toCharArray()
+ al = arrayOfNulls(75)
+ for (i in 0..74) {
+ val temp: MutableSet = HashSet()
+ al[i] = temp
+ }
+ for (mapping in mappings) {
+ al[mapping[0].code - '0'.code]!!.add(mapping[1])
+ }
+ return ans(c1.size, c2.size) == 1
+ }
+
+ private fun ans(m: Int, n: Int): Int {
+ var m = m
+ var n = n
+ if (m == 0) {
+ return 0
+ }
+ if (ans(m - 1, n) == 1) {
+ return 1
+ }
+ if (m >= n && (c1[m - 1] == c2[n - 1] || al[c2[n - 1].code - '0'.code]!!.contains(c1[m - 1]))) {
+ while (n >= 1 && (c1[m - 1] == c2[n - 1] || al[c2[n - 1].code - '0'.code]!!.contains(c1[m - 1]))) {
+ n--
+ m--
+ }
+ if (n == 0) {
+ return 1
+ }
+ }
+ return 0
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2301_2400/s2302_count_subarrays_with_score_less_than_k/readme.md b/src/main/kotlin/g2301_2400/s2302_count_subarrays_with_score_less_than_k/readme.md
new file mode 100644
index 00000000..e1ef76b1
--- /dev/null
+++ b/src/main/kotlin/g2301_2400/s2302_count_subarrays_with_score_less_than_k/readme.md
@@ -0,0 +1,79 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2302\. Count Subarrays With Score Less Than K
+
+Hard
+
+The **score** of an array is defined as the **product** of its sum and its length.
+
+* For example, the score of `[1, 2, 3, 4, 5]` is `(1 + 2 + 3 + 4 + 5) * 5 = 75`.
+
+Given a positive integer array `nums` and an integer `k`, return _the **number of non-empty subarrays** of_ `nums` _whose score is **strictly less** than_ `k`.
+
+A **subarray** is a contiguous sequence of elements within an array.
+
+**Example 1:**
+
+**Input:** nums = [2,1,4,3,5], k = 10
+
+**Output:** 6
+
+**Explanation:**
+
+The 6 subarrays having scores less than 10 are:
+
+- \[2] with score 2 \* 1 = 2.
+
+- \[1] with score 1 \* 1 = 1.
+
+- \[4] with score 4 \* 1 = 4.
+
+- \[3] with score 3 \* 1 = 3.
+
+- \[5] with score 5 \* 1 = 5.
+
+- \[2,1] with score (2 + 1) \* 2 = 6.
+
+Note that subarrays such as [1,4] and [4,3,5] are not considered because their scores are 10 and 36 respectively, while we need scores strictly less than 10.
+
+**Example 2:**
+
+**Input:** nums = [1,1,1], k = 5
+
+**Output:** 5
+
+**Explanation:**
+
+Every subarray except [1,1,1] has a score less than 5.
+
+[1,1,1] has a score (1 + 1 + 1) \* 3 = 9, which is greater than 5.
+
+Thus, there are 5 subarrays having scores less than 5.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* 1 <= nums[i] <= 105
+* 1 <= k <= 1015
+
+## Solution
+
+```kotlin
+class Solution {
+ fun countSubarrays(nums: IntArray, k: Long): Long {
+ var sum: Long = 0
+ var count: Long = 0
+ var i = 0
+ var j = 0
+ while (i < nums.size) {
+ sum += nums[i].toLong()
+ while (sum * (i - j + 1) >= k) {
+ sum -= nums[j++].toLong()
+ }
+ count += (i++ - j + 1).toLong()
+ }
+ return count
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2301_2400/s2303_calculate_amount_paid_in_taxes/readme.md b/src/main/kotlin/g2301_2400/s2303_calculate_amount_paid_in_taxes/readme.md
new file mode 100644
index 00000000..15979471
--- /dev/null
+++ b/src/main/kotlin/g2301_2400/s2303_calculate_amount_paid_in_taxes/readme.md
@@ -0,0 +1,85 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2303\. Calculate Amount Paid in Taxes
+
+Easy
+
+You are given a **0-indexed** 2D integer array `brackets` where brackets[i] = [upperi, percenti] means that the ith tax bracket has an upper bound of upperi and is taxed at a rate of percenti. The brackets are **sorted** by upper bound (i.e. upperi-1 < upperi for `0 < i < brackets.length`).
+
+Tax is calculated as follows:
+
+* The first upper0 dollars earned are taxed at a rate of percent0.
+* The next upper1 - upper0 dollars earned are taxed at a rate of percent1.
+* The next upper2 - upper1 dollars earned are taxed at a rate of percent2.
+* And so on.
+
+You are given an integer `income` representing the amount of money you earned. Return _the amount of money that you have to pay in taxes._ Answers within 10-5 of the actual answer will be accepted.
+
+**Example 1:**
+
+**Input:** brackets = \[\[3,50],[7,10],[12,25]], income = 10
+
+**Output:** 2.65000
+
+**Explanation:**
+
+The first 3 dollars you earn are taxed at 50%. You have to pay $3 \* 50% = $1.50 dollars in taxes.
+
+The next 7 - 3 = 4 dollars you earn are taxed at 10%. You have to pay $4 \* 10% = $0.40 dollars in taxes.
+
+The final 10 - 7 = 3 dollars you earn are taxed at 25%. You have to pay $3 \* 25% = $0.75 dollars in taxes. You have to pay a total of $1.50 + $0.40 + $0.75 = $2.65 dollars in taxes.
+
+**Example 2:**
+
+**Input:** brackets = \[\[1,0],[4,25],[5,50]], income = 2
+
+**Output:** 0.25000
+
+**Explanation:**
+
+The first dollar you earn is taxed at 0%. You have to pay $1 \* 0% = $0 dollars in taxes.
+
+The second dollar you earn is taxed at 25%. You have to pay $1 \* 25% = $0.25 dollars in taxes.
+
+You have to pay a total of $0 + $0.25 = $0.25 dollars in taxes.
+
+**Example 3:**
+
+**Input:** brackets = \[\[2,50]], income = 0
+
+**Output:** 0.00000
+
+**Explanation:** You have no income to tax, so you have to pay a total of $0 dollars in taxes.
+
+**Constraints:**
+
+* `1 <= brackets.length <= 100`
+* 1 <= upperi <= 1000
+* 0 <= percenti <= 100
+* `0 <= income <= 1000`
+* upperi is sorted in ascending order.
+* All the values of upperi are **unique**.
+* The upper bound of the last tax bracket is greater than or equal to `income`.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun calculateTax(brackets: Array, income: Int): Double {
+ // you can remove this line
+ if (income == 0) {
+ return 0.0
+ }
+ var sum = 0.0
+ var prev = 0.0
+ for (bracket in brackets) {
+ val salary = bracket[0].coerceAtMost(income).toDouble()
+ val tax = bracket[1].toDouble()
+ sum += (salary - prev) * tax
+ prev = salary
+ }
+ return sum / 100
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2301_2400/s2304_minimum_path_cost_in_a_grid/readme.md b/src/main/kotlin/g2301_2400/s2304_minimum_path_cost_in_a_grid/readme.md
new file mode 100644
index 00000000..2514b998
--- /dev/null
+++ b/src/main/kotlin/g2301_2400/s2304_minimum_path_cost_in_a_grid/readme.md
@@ -0,0 +1,81 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2304\. Minimum Path Cost in a Grid
+
+Medium
+
+You are given a **0-indexed** `m x n` integer matrix `grid` consisting of **distinct** integers from `0` to `m * n - 1`. You can move in this matrix from a cell to any other cell in the **next** row. That is, if you are in cell `(x, y)` such that `x < m - 1`, you can move to any of the cells `(x + 1, 0)`, `(x + 1, 1)`, ..., `(x + 1, n - 1)`. **Note** that it is not possible to move from cells in the last row.
+
+Each possible move has a cost given by a **0-indexed** 2D array `moveCost` of size `(m * n) x n`, where `moveCost[i][j]` is the cost of moving from a cell with value `i` to a cell in column `j` of the next row. The cost of moving from cells in the last row of `grid` can be ignored.
+
+The cost of a path in `grid` is the **sum** of all values of cells visited plus the **sum** of costs of all the moves made. Return _the **minimum** cost of a path that starts from any cell in the **first** row and ends at any cell in the **last** row._
+
+**Example 1:**
+
+
+
+**Input:** grid = \[\[5,3],[4,0],[2,1]], moveCost = \[\[9,8],[1,5],[10,12],[18,6],[2,4],[14,3]]
+
+**Output:** 17
+
+**Explanation:** The path with the minimum possible cost is the path 5 -> 0 -> 1.
+
+- The sum of the values of cells visited is 5 + 0 + 1 = 6.
+
+- The cost of moving from 5 to 0 is 3.
+
+- The cost of moving from 0 to 1 is 8.
+
+So the total cost of the path is 6 + 3 + 8 = 17.
+
+**Example 2:**
+
+**Input:** grid = \[\[5,1,2],[4,0,3]], moveCost = \[\[12,10,15],[20,23,8],[21,7,1],[8,1,13],[9,10,25],[5,3,2]]
+
+**Output:** 6
+
+**Explanation:** The path with the minimum possible cost is the path 2 -> 3.
+
+- The sum of the values of cells visited is 2 + 3 = 5.
+
+- The cost of moving from 2 to 3 is 1.
+
+So the total cost of this path is 5 + 1 = 6.
+
+**Constraints:**
+
+* `m == grid.length`
+* `n == grid[i].length`
+* `2 <= m, n <= 50`
+* `grid` consists of distinct integers from `0` to `m * n - 1`.
+* `moveCost.length == m * n`
+* `moveCost[i].length == n`
+* `1 <= moveCost[i][j] <= 100`
+
+## Solution
+
+```kotlin
+class Solution {
+ fun minPathCost(grid: Array, moveCost: Array): Int {
+ val m = grid.size
+ val n = grid[0].size
+ val dp = Array(m) { IntArray(n) }
+ System.arraycopy(grid[m - 1], 0, dp[m - 1], 0, n)
+ for (i in m - 2 downTo 0) {
+ for (j in 0 until n) {
+ var min = Int.MAX_VALUE
+ for (k in 0 until n) {
+ min = min.coerceAtMost(grid[i][j] + moveCost[grid[i][j]][k] + dp[i + 1][k])
+ }
+ dp[i][j] = min
+ }
+ }
+ var min = Int.MAX_VALUE
+ for (s in dp[0]) {
+ min = min.coerceAtMost(s)
+ }
+ return min
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2301_2400/s2305_fair_distribution_of_cookies/readme.md b/src/main/kotlin/g2301_2400/s2305_fair_distribution_of_cookies/readme.md
new file mode 100644
index 00000000..12eac6c9
--- /dev/null
+++ b/src/main/kotlin/g2301_2400/s2305_fair_distribution_of_cookies/readme.md
@@ -0,0 +1,84 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2305\. Fair Distribution of Cookies
+
+Medium
+
+You are given an integer array `cookies`, where `cookies[i]` denotes the number of cookies in the ith bag. You are also given an integer `k` that denotes the number of children to distribute **all** the bags of cookies to. All the cookies in the same bag must go to the same child and cannot be split up.
+
+The **unfairness** of a distribution is defined as the **maximum** **total** cookies obtained by a single child in the distribution.
+
+Return _the **minimum** unfairness of all distributions_.
+
+**Example 1:**
+
+**Input:** cookies = [8,15,10,20,8], k = 2
+
+**Output:** 31
+
+**Explanation:** One optimal distribution is [8,15,8] and [10,20]
+
+- The 1st child receives [8,15,8] which has a total of 8 + 15 + 8 = 31 cookies.
+
+- The 2nd child receives [10,20] which has a total of 10 + 20 = 30 cookies.
+
+The unfairness of the distribution is max(31,30) = 31.
+
+It can be shown that there is no distribution with an unfairness less than 31.
+
+**Example 2:**
+
+**Input:** cookies = [6,1,3,2,2,4,1,2], k = 3
+
+**Output:** 7
+
+**Explanation:** One optimal distribution is [6,1], [3,2,2], and [4,1,2]
+
+- The 1st child receives [6,1] which has a total of 6 + 1 = 7 cookies.
+
+- The 2nd child receives [3,2,2] which has a total of 3 + 2 + 2 = 7 cookies.
+
+- The 3rd child receives [4,1,2] which has a total of 4 + 1 + 2 = 7 cookies.
+
+The unfairness of the distribution is max(7,7,7) = 7.
+
+It can be shown that there is no distribution with an unfairness less than 7.
+
+**Constraints:**
+
+* `2 <= cookies.length <= 8`
+* 1 <= cookies[i] <= 105
+* `2 <= k <= cookies.length`
+
+## Solution
+
+```kotlin
+class Solution {
+ private var res = Int.MAX_VALUE
+ fun distributeCookies(c: IntArray, k: Int): Int {
+ val nums = IntArray(k)
+ dfs(c, nums, 0)
+ return res
+ }
+
+ private fun dfs(c: IntArray, nums: IntArray, cur: Int) {
+ if (cur == c.size) {
+ var r = 0
+ for (num in nums) {
+ r = r.coerceAtLeast(num)
+ }
+ res = res.coerceAtMost(r)
+ return
+ }
+ for (i in nums.indices) {
+ if (nums[i] + c[cur] > res) {
+ continue
+ }
+ nums[i] += c[cur]
+ dfs(c, nums, cur + 1)
+ nums[i] -= c[cur]
+ }
+ }
+}
+```
\ No newline at end of file
diff --git a/src/main/kotlin/g2301_2400/s2306_naming_a_company/readme.md b/src/main/kotlin/g2301_2400/s2306_naming_a_company/readme.md
new file mode 100644
index 00000000..f437152a
--- /dev/null
+++ b/src/main/kotlin/g2301_2400/s2306_naming_a_company/readme.md
@@ -0,0 +1,107 @@
+[](https://github.com/javadev/LeetCode-in-Kotlin)
+[](https://github.com/javadev/LeetCode-in-Kotlin/fork)
+
+## 2306\. Naming a Company
+
+Hard
+
+You are given an array of strings `ideas` that represents a list of names to be used in the process of naming a company. The process of naming a company is as follows:
+
+1. Choose 2 **distinct** names from `ideas`, call them ideaA and ideaB.
+2. Swap the first letters of ideaA and ideaB with each other.
+3. If **both** of the new names are not found in the original `ideas`, then the name ideaA ideaB (the **concatenation** of ideaA and ideaB, separated by a space) is a valid company name.
+4. Otherwise, it is not a valid name.
+
+Return _the number of **distinct** valid names for the company_.
+
+**Example 1:**
+
+**Input:** ideas = ["coffee","donuts","time","toffee"]
+
+**Output:** 6
+
+**Explanation:** The following selections are valid:
+
+- ("coffee", "donuts"): The company name created is "doffee conuts".
+
+- ("donuts", "coffee"): The company name created is "conuts doffee".
+
+- ("donuts", "time"): The company name created is "tonuts dime".
+
+- ("donuts", "toffee"): The company name created is "tonuts doffee".
+
+- ("time", "donuts"): The company name created is "dime tonuts".
+
+- ("toffee", "donuts"): The company name created is "doffee tonuts".
+
+Therefore, there are a total of 6 distinct company names.
+
+
+The following are some examples of invalid selections:
+
+- ("coffee", "time"): The name "toffee" formed after swapping already exists in the original array.
+
+- ("time", "toffee"): Both names are still the same after swapping and exist in the original array.
+
+- ("coffee", "toffee"): Both names formed after swapping already exist in the original array.
+
+**Example 2:**
+
+**Input:** ideas = ["lack","back"]
+
+**Output:** 0
+
+**Explanation:** There are no valid selections. Therefore, 0 is returned.
+
+**Constraints:**
+
+* 2 <= ideas.length <= 5 * 104
+* `1 <= ideas[i].length <= 10`
+* `ideas[i]` consists of lowercase English letters.
+* All the strings in `ideas` are **unique**.
+
+## Solution
+
+```kotlin
+class Solution {
+ fun distinctNames(a: Array): Long {
+ val m = Array>(26) { mutableSetOf() }
+ for (s in a) {
+ val i = s[0].code - 97
+ m[i].add(s.substring(1))
+ }
+
+ var res = 0L
+ for (i in m.indices) {
+ val b1 = m[i]
+ if (b1.isEmpty()) {
+ continue
+ }
+ for (y in i + 1 until m.size) {
+ val b2 = m[y]
+ if (b2.isEmpty()) {
+ continue
+ }
+ res += compare(b1, b2)
+ }
+ }
+
+ return res
+ }
+
+ fun compare(b1: MutableSet, b2: MutableSet