-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
Bug Report for https://neetcode.io/problems/three-integer-sum
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
let newArr = Array.from(nums);
This line for some reason considers newArr
as NOT an array. The error it gives me is -
TypeError: arr.sort is not a function
at /box/script.js:113:40
at Array.map ()
at processInput (/box/script.js:113:25)
at ReadStream. (/box/script.js:89:9)
at ReadStream.emit (node:events:513:28)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
The code:
threeSum(nums) {
let res = [];
for(let i = 0; i < nums.length; i++){
let newArr = Array.from(nums);
console.log("nums instanceof Array:", nums instanceof Array);
console.log("newArr instanceof Array:", newArr instanceof Array);
let target = 0 - nums[i];
newArr.splice(i, 1);
newArr.sort((a,b) => a -b);
......
Metadata
Metadata
Assignees
Labels
No labels