I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
Oh, I totally misread your code. I think when I read you were using new Set() you were calling new Set(nums) to reduce the length of the list you had to process. My bad.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Reducing this to a list of unique numbers would fail on ([1,2,2,5], 4) because though 2 + 2 == 4, it'd never get checked.
I think I'd do this by something like:
Could also hack out things like, if the total is positive, don't check two negatives.
Hmm, I’m not quite following. When is this reduced to a list of unique numbers?
Oh, I totally misread your code. I think when I read you were using
new Set()
you were callingnew Set(nums)
to reduce the length of the list you had to process. My bad.