LeetCode-Feedback / LeetCode-Feedback

674 stars 332 forks source link

[BUG] - <title> #22246

Closed lekan-pvp closed 5 months ago

lekan-pvp commented 6 months ago

LeetCode Username

lekanlekan

Problem Number, Title, and Link

Rotate Array

Bug Category

Incorrect test case (Output of test case is incorrect as per the problem statement)

Bug Description

The function has no return value. It is unclear how to get an answer. It does not accept output to the screen either. At startup, everything passes. Returns an error when sending.

Language Used for Code

Go

Code used for Submit/Run operation

func rotate(nums []int, k int)  {
    if len(nums)%2 != 0 {
        k++
    }

    fmt.Println(append(nums[k:], nums[:k]...))
}

Expected behavior

the test should pass as at running

Screenshots

2024-05-13 23-16-59

Additional context

No response

exalate-issue-sync[bot] commented 6 months ago

Winston Tang commented: Dear lekanlekan,

Thank you for reaching out to us. From your report, it seems there might be a misunderstanding about the requirements of the "Rotate Array" problem. The problem expects you to rotate the array in-place, meaning you are required to modify the input array directly without allocating additional space (i.e., returning/printing a new array).

In your code, it seems you're trying to print the rotated array, which isn’t the expected solution. You are advised to update the 'nums' array such that it becomes the rotated array after the function.

You can reference the problem's discussion section to see how other users approach this problem. It might help clarify the task.

We hope this clarifies the situation. Please feel free to reach out if you have any other questions or concerns.

Best, LeetCode Support Team.