Practice / Software

Two sum

Easy · Coding (typed)

Given an array of integers nums and a target, return the indices of the two numbers that add up to target. Assume exactly one answer exists and you may not use the same element twice. Write the function, then say its time and space cost.

Create a free account to answer it and get scored on what a strong answer covers.