Skip to content

Commit b053830

Browse files
authored
Merge pull request #236 from moongilj/fix-239
Fix typo and update syntax in SlidingWindowMaximum
2 parents 7a4ca59 + ffe1518 commit b053830

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Array/SlidingWindowMaximum.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
class SlidingWindowMaximum {
11-
func maxSlidingWindow(nums: [Int], _ k: Int) -> [Int] {
11+
func maxSlidingWindow(_ nums: [Int], _ k: Int) -> [Int] {
1212
var maxIdx = [Int]()
1313
var res = [Int]()
1414

@@ -20,14 +20,14 @@ class SlidingWindowMaximum {
2020
maxIdx.append(i)
2121

2222
if i >= k - 1 {
23-
if decreaseIndexQueue.first! + k == i {
24-
decreaseIndexQueue.removeFirst()
23+
if maxIdx.first! + k == i {
24+
maxIdx.removeFirst()
2525
}
2626

27-
res.append(nums[decreaseIndexQueue.first!])
27+
res.append(nums[maxIdx.first!])
2828
}
2929
}
3030

3131
return res
3232
}
33-
}
33+
}

0 commit comments

Comments
 (0)