Skip to content

Commit 7459e05

Browse files
committed
Fixed sonar
1 parent a97458c commit 7459e05

File tree

1 file changed

+6
-6
lines changed
  • src/main/kotlin/g3601_3700/s3660_jump_game_ix

1 file changed

+6
-6
lines changed

src/main/kotlin/g3601_3700/s3660_jump_game_ix/Solution.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Solution {
1515
if (st.isNotEmpty()) {
1616
prev = st.peek()!!
1717
}
18-
while (!st.isEmpty() && nums[i] < nums[st.peek()!!]) {
18+
while (st.isNotEmpty() && nums[i] < nums[st.peek()!!]) {
1919
uf.union(st.pop(), i)
2020
}
2121
if (nums[i] > nums[prev]) {
@@ -27,10 +27,10 @@ class Solution {
2727
st.clear()
2828
for (i in n - 1 downTo 0) {
2929
var prev = i
30-
if (!st.isEmpty()) {
30+
if (st.isNotEmpty()) {
3131
prev = st.peek()!!
3232
}
33-
while (!st.isEmpty() && nums[i] > nums[st.peek()!!]) {
33+
while (st.isNotEmpty() && nums[i] > nums[st.peek()!!]) {
3434
uf.union(st.pop(), i)
3535
}
3636
if (nums[i] < nums[prev]) {
@@ -39,14 +39,14 @@ class Solution {
3939
st.push(prev)
4040
}
4141
}
42-
val map = HashMap<Int?, Int?>()
42+
val map = HashMap<Int, Int>()
4343
for (i in 0..<n) {
4444
val root = uf.find(i)
45-
map.put(root, max(map.getOrDefault(root, Int.Companion.MIN_VALUE)!!, nums[i]))
45+
map.put(root, max(map.getOrDefault(root, Int.Companion.MIN_VALUE), nums[i]))
4646
}
4747
val ans = IntArray(n)
4848
for (i in 0..<n) {
49-
ans[i] = map.get(uf.find(i))!!
49+
ans[i] = map[uf.find(i)]!!
5050
}
5151
return ans
5252
}

0 commit comments

Comments
 (0)