Sobes.tech
Junior — Senior

Determining the indices of a pair of numbers with the required sum

livecode

Task condition

Given an array of integers arr and a target value need, find two elements whose sum equals need, and return their indices in the array. It is guaranteed that the input data is correct and a solution exists. Input: numbers = [2, 7, 11, 15], target = 9 Output: [0, 1]