Write a function that takes an array of integers and a target number.
The function should find two different integers in the array that give the target value when added together. Return the indices in a tuple [e.g. (index1, index2)]. Some tests will have multiple solutions.
Test Cases
[1234,5678,9012], 14690
[1,2,3], 4
[2,2,3], 4
[5,10,15,20,25,30], 50
Happy coding!
This challenge comes from wthit56 on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!
Oldest comments (9)
Javascript
Doesn't this return the values that sum up to the target value and not their indices in the array?
It did. I've now corrected it, I hope.
I can't believe thwre are people saying JS is beautiful
Scala
And the tests
Rust:
TypeScript
python
# defines result of the code
Some comments may only be visible to logged-in visitors. Sign in to view all comments.