Daily Coding Problem 1
This website sends an email to you with a programming problem, from legitimate interview questions.
I like to use these to get more familiar with a new language, or like doing crossword puzzles, so I’ll post my solutions here. I’ll start with JavaScript but I might change to something else down the track.
Today’s problem:
Given a list of numbers and a number k, return whether any two numbers from the list add up to k.
For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.
Bonus: Can you do this in one pass?
My solution:
1 | const addUpToK = (array, k) => { |
Output:
1 | ➜ node addUpToK.js |