This solution is generated by ChatGPT, correctness is not guaranteed.

AI solution for JavaScript Coding Question on BFE.dev
106. Find two numbers that sum up to 0

Here's one possible solution to the problem:

function findTwo(arr) {
  let map = {};
  for (let i = 0; i < arr.length; i++) {
    let complement = -arr[i];
    if (complement in map) {
      return [map[complement], i];
    } else {
      map[arr[i]] = i;
    }
  }
  return null;
}

The function uses a hash map to keep track of the indices of the numbers as they are processed. For each number arr[i] in the input array, it calculates its complement complement as -arr[i], which is the value it needs to sum up to 0. If the complement is already in the hash map, it means that there is a pair of numbers that sum up to 0, and we return their indices. If not, we add the current number to the hash map with its index.

The time complexity of this algorithm is O(n), where n is the length of the input array, since we need to iterate through the array only once. The space complexity is also O(n), because we need to store at most all the numbers in the hash map.