Target Indices
Start Timer
0:00:00
Given an array and a target integer, write a function sum_pair_indices that returns the indices of two integers in the array that add up to the target integer. If not found, just return an empty list.
Note: Can you do it on time?
Note: Even though there could be many solutions, only one needs to be returned.
Example 1:
Input:
array = [1 2 3 4]
target = 5
Output:
def sum_pair_indices(array, target) -> [0 3] or [1 2]
Example 2:
Input:
array = [3]
target = 6
Output:
Do NOT return [0 0] as you can't use an index twice.
.
.
.
.
.
.
.
.
.
Comments