Use a hash map to store seen values and their indices. For each element x, check if (target - x) is in the map in O(1) time.