Bug Report for https://neetcode.io/problems/three-integer-sum
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Description
I'm using Swift to solve the Three Sum problem.
False warning on Submit: variable 'nums' was never mutated despite using let
I found an inconsistency between the Run and Submit environments for the Swift solution to the Three Sum problem.
My submitted solution declares the sorted array as a constant:
func threeSum(_ nums: [Int]) -> [[Int]] {
let numSorted = nums.sorted()
var results: [[Int]] = []
for (i, e) in numSorted.enumerated() {
if i > 0 && e == numSorted[i - 1] { continue }
var pointerL = i + 1
var pointerR = numSorted.count - 1
while pointerL < pointerR {
let threeSum = numSorted[i] + numSorted[pointerL] + numSorted[pointerR]
if threeSum == 0 {
results.append([numSorted[i], numSorted[pointerL], numSorted[pointerR]])
pointerL += 1
while numSorted[pointerL] == numSorted[pointerL - 1] {
pointerL += 1
}
} else if threeSum > 0 {
pointerR -= 1
} else {
pointerL += 1
}
}
}
return results
}
When I click Run, my solution compiles and runs successfully. However, when I click Submit, I receive the following warning:
warning: variable 'nums' was never mutated; consider changing to 'let' constant
The warning points to this code:
However, my submitted solution does not contain that code. Instead, I use:
let numSorted = nums.sorted()
It seems the Submit environment is compiling a different or outdated version of my code.
Expected behavior
The Submit environment should compile the exact code that was submitted and report diagnostics that match the submitted source.
Bug Report for https://neetcode.io/problems/three-integer-sum
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Description
I'm using Swift to solve the Three Sum problem.
False warning on Submit: variable 'nums' was never mutated despite using let
I found an inconsistency between the Run and Submit environments for the Swift solution to the Three Sum problem.
My submitted solution declares the sorted array as a constant:
When I click Run, my solution compiles and runs successfully. However, when I click Submit, I receive the following warning:
The warning points to this code:
However, my submitted solution does not contain that code. Instead, I use:
It seems the Submit environment is compiling a different or outdated version of my code.
Expected behavior
The Submit environment should compile the exact code that was submitted and report diagnostics that match the submitted source.