106. Find two numbers that sum up to 0

JavaScriptAlgorithm

easy  - accepted / - tried

Given an array of integers, find two number that sums up to 0, return their indices.

There might be multiple pairs, any of them would do. If not found, return null


findTwo([1,2,3,-1])
// [0,3]

findTwo([1,2,3,-1,-2,0])
// [0,3] or [1,4] or [5, 5]

findTwo([1,2,3,4])
// null

Let's try to solve this problem within 10 minutes.

Discuss(65)