-
Notifications
You must be signed in to change notification settings - Fork 385
Closed
Description
Your LeetCode username
Juriah
Category of the bug
- Question
- Solution
- Language
- Missing Test Cases
Wrong test case result
Description of the bug
The code runs wrong on last iteration of slice - instead of min it uses max or something with such behavior
Code you used for Submit/Run operation
func writeRes(nums []int, answer * int) {
n := len(nums)
if n == 1 {
*answer = nums[0]
return
}
newNum := nums[:n/2]
for i := 0; i < n/2; i += 2 {
newNum[i] = int(math.Min(float64(nums[2*i]), float64(nums[2*i+1])))
}
for i := 1; i < n/2; i += 2 {
newNum[i] = int(math.Max(float64(nums[2*i]), float64(nums[2*i+1])))
}
writeRes(newNum, answer)
}
func minMaxGame(nums []int, ) (answer int) {
writeRes(nums, &answer)
return
}
Language used for code
Golang
Expected behavior
I expected to run testcase 72 same as solution through debugger...