Medium20 min

Two Sum

Return the indexes of two distinct numbers in value whose sum equals extra. Each input has exactly one solution.

Your function

Implement solve(value, extra) in JavaScript. Return the answer; printing alone does not count as a result.

Examples

Input: [[2,7,11,15],9]
Output: [0,1]
Input: [[3,2,4],6]
Output: [1,2]

Constraints

Input contains at most 1,000 values or characters. Numbers are finite integers. Inputs follow the structure shown in the examples.

13px
main.jsYour ideas, in code.
Loading your editor…
Run your code to see the output here.
Ready to buildUTF-84 lines

Test freely without an account. Signed-in submissions are checked independently by the isolated execution service before progress is awarded.