Skip to content

Commit c593af3

Browse files
authored
Fixed Idea warnings
1 parent 641cf1e commit c593af3

File tree

19 files changed

+43
-51
lines changed

19 files changed

+43
-51
lines changed

src/main/kotlin/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package g0001_0100.s0034_find_first_and_last_position_of_element_in_sorted_array
44
// #Algorithm_II_Day_1_Binary_Search #Binary_Search_I_Day_5 #Top_Interview_150_Binary_Search
55
// #Big_O_Time_O(log_n)_Space_O(1) #2023_07_05_Time_174_ms_(100.00%)_Space_37.8_MB_(71.70%)
66

7-
class Solution constructor() {
7+
class Solution {
88
fun searchRange(nums: IntArray, target: Int): IntArray {
99
val ans = IntArray(2)
1010
ans[0] = helper(nums, target, false)

src/main/kotlin/g0001_0100/s0068_text_justification/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Solution {
5555
startWord = i + 1
5656
// resetting these to 0 for processing next line
5757
lineTotal = 0
58-
numWordsOnLine = lineTotal
58+
numWordsOnLine = 0
5959
// need a new StringBuilder for the next line
6060
sb = StringBuilder(maxWidth)
6161
}

src/main/kotlin/g0201_0300/s0289_game_of_life/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Solution {
4747
}
4848

4949
private fun compute(board: Array<IntArray>, r: Int, c: Int): Int {
50-
var ret: Int = 0
50+
var ret = 0
5151
for (arr in dim) {
5252
val row = arr[0] + r
5353
val col = arr[1] + c

src/main/kotlin/g0201_0300/s0292_nim_game/Solution.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ package g0201_0300.s0292_nim_game
44

55
class Solution {
66
fun canWinNim(n: Int): Boolean {
7-
if (n % 4 == 0) {
8-
return false
9-
}
10-
return true
7+
return n % 4 != 0
118
}
129
}

src/main/kotlin/g0301_0400/s0304_range_sum_query_2d_immutable/NumMatrix.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ package g0301_0400.s0304_range_sum_query_2d_immutable
55
// #2022_11_07_Time_1373_ms_(85.71%)_Space_129.1_MB_(75.00%)
66

77
class NumMatrix(matrix: Array<IntArray>) {
8-
private val M = matrix.size
9-
private val N = if (M > 0) matrix[0].size else 0
8+
private val m = matrix.size
9+
private val n = if (m > 0) matrix[0].size else 0
1010

11-
var array = Array<IntArray> (M + 1) { IntArray(N + 1) }
11+
var array = Array<IntArray> (m + 1) { IntArray(n + 1) }
1212

1313
init {
14-
for (i in 1..M) {
15-
for (j in 1..N) {
14+
for (i in 1..m) {
15+
for (j in 1..n) {
1616
array[i][j] = matrix[i - 1][j - 1] + array[i][j - 1] + array[i - 1][j] - array[i - 1][j - 1]
1717
}
1818
}

src/main/kotlin/g0301_0400/s0310_minimum_height_trees/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Solution {
1818
while (queue.isNotEmpty()) {
1919
val size = queue.size
2020
val newLeaves = mutableListOf<Int>()
21-
for (_sz in 0 until size) {
21+
for (sz in 0 until size) {
2222
val cur = queue.removeFirst()
2323
newLeaves.add(cur)
2424
for (next in graph[cur]) {

src/main/kotlin/g0301_0400/s0312_burst_balloons/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Solution {
1818
while (ei < nums.size) {
1919
val l = if (si - 1 == -1) 1 else nums[si - 1]
2020
val r = if (ei + 1 == nums.size) 1 else nums[ei + 1]
21-
var maxAns = -1e7.toInt()
21+
var maxAns = (-1e7).toInt()
2222
for (cut in si..ei) {
2323
val leftAns = if (si == cut) 0 else dp[si][cut - 1]
2424
val rightAns = if (ei == cut) 0 else dp[cut + 1][ei]

src/main/kotlin/g0401_0500/s0409_longest_palindrome/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Solution {
1111
for (c in s.toCharArray()) {
1212
set.flip(c.code - 'A'.code)
1313
}
14-
return if (set.isEmpty()) {
14+
return if (set.isEmpty) {
1515
s.length
1616
} else {
1717
s.length - set.cardinality() + 1

src/main/kotlin/g0701_0800/s0770_basic_calculator_iv/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Solution {
9797
}
9898

9999
private fun make(cur: String): Node {
100-
val ans: Node = Node()
100+
val ans = Node()
101101
val tmp: MutableList<String> = ArrayList()
102102
if (Character.isDigit(cur[0])) {
103103
ans.update(tmp, Integer.valueOf(cur))

src/main/kotlin/g0801_0900/s0811_subdomain_visit_count/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Solution {
88
val fmap: MutableMap<String, Int> = HashMap()
99
for (s in d) {
1010
var rep = 0
11-
var i: Int = 0
11+
var i = 0
1212
while (i < s.length) {
1313
val c = s[i]
1414
rep = if (c in '0'..'9') {

0 commit comments

Comments
 (0)