diff --git a/src/main/kotlin/g0901_1000/s0989_add_to_array_form_of_integer/Solution.kt b/src/main/kotlin/g0901_1000/s0989_add_to_array_form_of_integer/Solution.kt index d5ab2e95d..7ce338a92 100644 --- a/src/main/kotlin/g0901_1000/s0989_add_to_array_form_of_integer/Solution.kt +++ b/src/main/kotlin/g0901_1000/s0989_add_to_array_form_of_integer/Solution.kt @@ -5,9 +5,9 @@ package g0901_1000.s0989_add_to_array_form_of_integer @Suppress("NAME_SHADOWING") class Solution { - fun addToArrayForm(num: IntArray, k: Int): List { + fun addToArrayForm(num: IntArray, k: Int): List { var k = k - val result = ArrayList() + val result = ArrayList() var carry = 0 for (i in num.indices.reversed()) { val temp = num[i] + k % 10 + carry diff --git a/src/main/kotlin/g1001_1100/s1048_longest_string_chain/Solution.kt b/src/main/kotlin/g1001_1100/s1048_longest_string_chain/Solution.kt index 63650c1a3..1a085c5d0 100644 --- a/src/main/kotlin/g1001_1100/s1048_longest_string_chain/Solution.kt +++ b/src/main/kotlin/g1001_1100/s1048_longest_string_chain/Solution.kt @@ -5,7 +5,7 @@ package g1001_1100.s1048_longest_string_chain class Solution { fun longestStrChain(words: Array): Int { - val lenStr = arrayOfNulls?>(20) + val lenStr = arrayOfNulls>(20) for (word in words) { val len = word.length if (lenStr[len] == null) { diff --git a/src/main/kotlin/g1601_1700/s1639_number_of_ways_to_form_a_target_string_given_a_dictionary/Solution.kt b/src/main/kotlin/g1601_1700/s1639_number_of_ways_to_form_a_target_string_given_a_dictionary/Solution.kt index 162d456bd..e92e2eb53 100644 --- a/src/main/kotlin/g1601_1700/s1639_number_of_ways_to_form_a_target_string_given_a_dictionary/Solution.kt +++ b/src/main/kotlin/g1601_1700/s1639_number_of_ways_to_form_a_target_string_given_a_dictionary/Solution.kt @@ -6,7 +6,7 @@ package g1601_1700.s1639_number_of_ways_to_form_a_target_string_given_a_dictiona class Solution { fun numWays(words: Array, target: String): Int { val counts = precompute(words) - val memo = Array(target.length) { arrayOfNulls(words[0].length) } + val memo = Array(target.length) { arrayOfNulls(words[0].length) } return solve(memo, counts, words, target, 0, 0) } diff --git a/src/main/kotlin/g2001_2100/s2019_the_score_of_students_solving_math_expression/Solution.kt b/src/main/kotlin/g2001_2100/s2019_the_score_of_students_solving_math_expression/Solution.kt index be0744309..74fa458ae 100644 --- a/src/main/kotlin/g2001_2100/s2019_the_score_of_students_solving_math_expression/Solution.kt +++ b/src/main/kotlin/g2001_2100/s2019_the_score_of_students_solving_math_expression/Solution.kt @@ -12,7 +12,7 @@ class Solution { val st = ArrayDeque() val n = s.length var i = 0 - dp = Array(n) { arrayOfNulls?>(n) } + dp = Array(n) { arrayOfNulls>(n) } while (i < n) { if (s[i].code - '0'.code >= 0 && s[i].code - '9'.code <= 0) { st.push(s[i].code - '0'.code) diff --git a/src/main/kotlin/g2401_2500/s2452_words_within_two_edits_of_dictionary/Solution.kt b/src/main/kotlin/g2401_2500/s2452_words_within_two_edits_of_dictionary/Solution.kt index 04ff57650..7632aeb71 100644 --- a/src/main/kotlin/g2401_2500/s2452_words_within_two_edits_of_dictionary/Solution.kt +++ b/src/main/kotlin/g2401_2500/s2452_words_within_two_edits_of_dictionary/Solution.kt @@ -6,7 +6,7 @@ class Solution { private var root: Node? = null internal class Node { - var childs = HashMap() + var childs = HashMap() } private fun insert(s: String) { diff --git a/src/main/kotlin/g3201_3300/s3245_alternating_groups_iii/Solution.kt b/src/main/kotlin/g3201_3300/s3245_alternating_groups_iii/Solution.kt index 3544457b3..87e95c933 100644 --- a/src/main/kotlin/g3201_3300/s3245_alternating_groups_iii/Solution.kt +++ b/src/main/kotlin/g3201_3300/s3245_alternating_groups_iii/Solution.kt @@ -5,7 +5,7 @@ package g3201_3300.s3245_alternating_groups_iii import java.util.BitSet class Solution { - fun numberOfAlternatingGroups(colors: IntArray, queries: Array): MutableList { + fun numberOfAlternatingGroups(colors: IntArray, queries: Array): List { val n = colors.size val set = BitSet() val bit = BIT(n) @@ -14,7 +14,7 @@ class Solution { add(set, bit, n, i) } } - val ans: MutableList = ArrayList() + val ans: MutableList = ArrayList() for (q in queries) { if (q[0] == 1) { if (set.isEmpty) { diff --git a/src/main/kotlin/g3201_3300/s3283_maximum_number_of_moves_to_kill_all_pawns/Solution.kt b/src/main/kotlin/g3201_3300/s3283_maximum_number_of_moves_to_kill_all_pawns/Solution.kt index e988b4a3e..3acfc534d 100644 --- a/src/main/kotlin/g3201_3300/s3283_maximum_number_of_moves_to_kill_all_pawns/Solution.kt +++ b/src/main/kotlin/g3201_3300/s3283_maximum_number_of_moves_to_kill_all_pawns/Solution.kt @@ -61,10 +61,10 @@ class Solution { if (x1 == x2 && y1 == y2) { return 0 } - val visited = Array(50) { BooleanArray(50) } + val visited = Array(50) { BooleanArray(50) } val queue: Queue = LinkedList() queue.offer(intArrayOf(x1, y1, 0)) - visited[x1]!![y1] = true + visited[x1][y1] = true while (queue.isNotEmpty()) { val current = queue.poll() val x = current[0] @@ -76,9 +76,9 @@ class Solution { if (nx == x2 && ny == y2) { return moves + 1 } - if (nx >= 0 && nx < 50 && ny >= 0 && ny < 50 && !visited[nx]!![ny]) { + if (nx >= 0 && nx < 50 && ny >= 0 && ny < 50 && !visited[nx][ny]) { queue.offer(intArrayOf(nx, ny, moves + 1)) - visited[nx]!![ny] = true + visited[nx][ny] = true } } } diff --git a/src/main/kotlin/g3401_3500/s3486_longest_special_path_ii/Solution.kt b/src/main/kotlin/g3401_3500/s3486_longest_special_path_ii/Solution.kt index 5b6f4142f..f62a0ed3a 100644 --- a/src/main/kotlin/g3401_3500/s3486_longest_special_path_ii/Solution.kt +++ b/src/main/kotlin/g3401_3500/s3486_longest_special_path_ii/Solution.kt @@ -53,7 +53,7 @@ class Solution { if (last.containsKey(nums[nextNode])) { nextLeft.add(last[nums[nextNode]]!! + 1) } - nextLeft.sortWith(Comparator.naturalOrder()) + nextLeft.sortWith(Comparator.naturalOrder()) while (nextLeft.size > 2) { nextLeft.removeAt(0) } diff --git a/src/main/kotlin/g3401_3500/s3490_count_beautiful_numbers/Solution.kt b/src/main/kotlin/g3401_3500/s3490_count_beautiful_numbers/Solution.kt index 24e820d04..3bde7d146 100644 --- a/src/main/kotlin/g3401_3500/s3490_count_beautiful_numbers/Solution.kt +++ b/src/main/kotlin/g3401_3500/s3490_count_beautiful_numbers/Solution.kt @@ -9,7 +9,7 @@ class Solution { private fun countBeautiful(x: Int): Int { val digits = getCharArray(x) - val dp = HashMap() + val dp = HashMap() return solve(0, 1, 0, 1, digits, dp) } @@ -24,7 +24,7 @@ class Solution { sum: Int, prod: Int, digits: CharArray, - dp: HashMap, + dp: HashMap, ): Int { if (i == digits.size) { return if (sum > 0 && prod % sum == 0) {