Challenge: Two Sum | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

Challenge: Two Sum

An ARRAY of numbers is given and a SUM Variable. Find one pair out of the array that will sum up to the target. Example: [1,2,4,6,8] 9 Answer: 1 8

21st Jan 2018, 7:19 PM
Serge Gerodes
Serge Gerodes - avatar
7 Answers
22nd Jan 2018, 4:45 AM
Justine Ogaraku
Justine Ogaraku - avatar
+ 6
Oneliner. All the ways to sum including ones involving repetitions https://code.sololearn.com/cWLGyFH7weto/?ref=app
21st Jan 2018, 10:27 PM
VcC
VcC - avatar
+ 5
https://code.sololearn.com/#py
21st Jan 2018, 7:29 PM
Serge Gerodes
Serge Gerodes - avatar
23rd Jan 2018, 11:29 AM
Med Arezki
Med Arezki - avatar
23rd Jan 2018, 12:41 PM
davy hermans
davy hermans - avatar
+ 2
New version. Allows to find solutions with or without repetitions https://code.sololearn.com/cWLGyFH7weto/?ref=app
22nd Jan 2018, 2:35 PM
VcC
VcC - avatar
+ 1
Response in Ruby; function finds all summing pairs for any input array and sum, returns pairs while excluding repeats. https://code.sololearn.com/cP8EJm3Sw7f4/?ref=app
22nd Jan 2018, 10:05 PM
André
André - avatar