Skip to content

Missing Test Case - 2293. Min Max Game #9531

@close2code-palm

Description

@close2code-palm

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...

Screenshots

Additional context

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions