finding two index values that add up to a certain value
Posted: Wed Jan 06, 2010 9:42 pm
I need a function that takes an array of integers as an argument and returns an array of the first pair of indexes that add up to 10.
So, given an array:
3 and 7 are the first pair of values that add up to 10 so the function would return
Since 3 and 7 are at index 1 and 3 respectively.
Anybody have any ideas?
So, given an array:
Code: Select all
array(1,3,5,7,9)
Code: Select all
array(1,3)
Anybody have any ideas?