Skip to content

Bug Report for concatenation-of-array #5952

Description

@Neeraj-Singh-Codes

Bug Report for https://neetcode.io/problems/concatenation-of-array

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.

The following JavaScript solution is currently being accepted, even though it returns a 2D array instead of the required concatenated 1D array.

class Solution {
/**
* @param {number[]} nums
* @return {number[]}
*/
getConcatenation(nums) {
let ans = []
ans.push(nums,nums)
return ans
}
}

ans.push(nums, nums) produces:
[[1, 2, 3], [1, 2, 3]]

whereas the expected output is:
[1, 2, 3, 1, 2, 3]

This solution should not be accepted, as it does not satisfy the problem requirements.
It appears that the JavaScript validator may be flattening nested arrays or otherwise comparing the output incorrectly.

Suggested fix:
Update the validator to verify the exact output structure instead of accepting nested arrays.
Add test cases that explicitly reject 2D arrays, for example:
Input: [1,2,3]
Expected: [1,2,3,1,2,3]
Incorrect (currently accepted): [[1,2,3],[1,2,3]]

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions