Skip to content

Fixed Idea warnings #800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/main/kotlin/g0701_0800/s0770_basic_calculator_iv/Solution.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Solution {
return ans
}

fun evaluate(vars: Map<String?, Int>): Node {
fun evaluate(vars: Map<String, Int>): Node {
val ans = Node()
for (cur in mem.keys) {
var cnt = mem[cur]!!
Expand Down Expand Up @@ -137,14 +137,14 @@ class Solution {
return a.sub(b)
}

fun basicCalculatorIV(expression: String?, evalvarS: Array<String?>?, evalintS: IntArray?): List<String> {
fun basicCalculatorIV(expression: String, evalvars: Array<String>, evalints: IntArray): List<String> {
val ans: List<String> = ArrayList()
if (expression.isNullOrEmpty() || evalvarS == null || evalintS == null) {
if (expression.isEmpty()) {
return ans
}
val vars: MutableMap<String?, Int> = HashMap()
for (i in evalvarS.indices) {
vars[evalvarS[i]] = evalintS[i]
val vars: MutableMap<String, Int> = HashMap()
for (i in evalvars.indices) {
vars[evalvars[i]] = evalints[i]
}
val n = expression.length
val numS = ArrayDeque<Node>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class MKAverage(private val capacity: Int, private val boundary: Int) {
val count = nums[num]
if (skipCount < 0) {
sum += num * min(count, numsCount)
numsCount = (numsCount - min(count, numsCount)).toInt()
numsCount = numsCount - min(count, numsCount)
} else {
skipCount -= count
if (skipCount < 0) {
sum += num * min(abs(skipCount), numsCount)
numsCount = (numsCount - min(abs(skipCount), numsCount)).toInt()
numsCount = numsCount - min(abs(skipCount), numsCount)
}
}
if (numsCount == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class Solution {
val bb = if (pq2.isNotEmpty()) pq2.poll() else 0
result[i] = max(0, (a.toLong() * b * c))
result[i] = max(result[i], max(0, (a.toLong() * aa * bb)))
.toLong()
pq = PriorityQueue { x: Int, y: Int -> y - x }
pq.add(a)
pq.add(b)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ class Solution {
}
var ans: Long = 0
val s = LongArray(one + 1)
val n = (min(zero, one) + 1).toInt()
val n = min(zero, one) + 1
for (
groups0 in (zero + limit - 1) / limit..min(zero, n)
.toInt()
) {
val s0 = calc(groups0, zero, limit)
for (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Solution {
}
var ans = Long.Companion.MAX_VALUE
for (x in longArrayOf(dp0, dp1, dp2, dp3, dp4, dp5)) {
ans = min(ans, x).toLong()
ans = min(ans, x)
}
return ans
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Solution {
val diff = original[i] - original[i - 1]
low = max((low + diff), bounds[i][0])
high = min((high + diff), bounds[i][1])
ans = min(ans, (high - low + 1)).toInt()
ans = min(ans, high - low + 1)
}
return max(ans, 0)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Solution {
f[n + 1] = n + 1
f[n] = h[n]
for (i in n - 1 downTo 1) {
f[i] = min(h[i], f[i + 1]).toInt()
f[i] = min(h[i], f[i + 1])
}
// forbiddenCount(x) returns (n - x + 1) if x <= n, else 0.
// This is the number of forbidden subarrays starting at some i when f[i] = x.
Expand All @@ -53,7 +53,7 @@ class Solution {
continue
}
// Simulate removal: new candidate at j becomes d2[j]
val newCandidate = if (j < n) min(d2[j], f[j + 1]).toInt() else d2[j]
val newCandidate = if (j < n) min(d2[j], f[j + 1]) else d2[j]
// We'll recompute the new f values for indices 1..j.
// Let newF[i] denote the updated value.
// For i > j, newF[i] remains as original f[i].
Expand Down