Retired

Two Sum Min Index (retired)

Description:

Given an array of integers numbers and an integer target, find the indices of two numbers in the array such that they add up to the given target.

You may not assume that each input would have exactly one solution, and you may not use the same element twice. However you may assume that each array has a length of at least two

You should return the sum of the indices that have the lowest. If there are no possible sums, return -1

EX1: Given the array [8, 4, 2, 6, 12, 43, 95, 14] and target 18, there should be two solutions (6,12) and (4, 14) The indices are [3,4] and [1,7] respectively.

Your output should be 7 as 3 + 4 < 1 + 7 (7 < 8)

Ex 2: Given the array [1, 2] and target 4, we can see that there is no way to get a sum of 4 using 1 + 2 so in this case your output should be -1

Stats:

CreatedAug 16, 2023
Warriors Trained7
Total Skips0
Total Code Submissions10
Total Times Completed5
JavaScript Completions1
Python Completions5
Total Stars0
% of votes with a positive feedback rating0% of 4
Total "Very Satisfied" Votes0
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes4
Total Rank Assessments3
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • Soham-West Avatar
Ad