Skip to content

Bug Report for intersection-of-two-arrays #5693

@evanemolo

Description

@evanemolo

Bug Report for https://neetcode.io/problems/intersection-of-two-arrays

class Solution {
    /**
     * @param {number[]} nums1
     * @param {number[]} nums2
     * @return {number[]}
     */
    intersection(nums1, nums2) {
        const nums1Set = new Set(nums1);
        const nums2Set = new Set(nums2);
        const intersection = nums1Set.intersection(nums2Set);
        return intersection;
    }
}

Returns the error:

TypeError: arr1.slice is not a function
    at TestSolution.isValid (/box/main.js:40:14)
    at processInput (/box/main.js:95:30)
    at ReadStream.<anonymous> (/box/main.js:60:9)
    at ReadStream.emit (node:events:519:28)
    at endReadableNT (node:internal/streams/readable:1698:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)

Using the other 2026 Set methods return similar errors. These are supported by Node 22. The JS item in the language dropdown states it's using Node 22.08.

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