Easy49.2% acceptance

Two Sum

Find two numbers in an array that add up to a given target.

Topics

ArraysHashing

Examples

Input: nums = [2,7,11,15], target = 9
Output: [0,1]
2 + 7 = 9.
Input: nums = [3,2,4], target = 6
Output: [1,2]
2 + 4 = 6.

Expected Complexity

O(n) time and O(n) space using a hash map.

What happens after Submit?

ERROR DNA analyzes your submission and identifies recurring patterns in your mistakes.

solution.cppC++17
Loading...
C++17