Given an array of integers nums and an integer target, return true if there exist two distinct indices i and j such that nums[i] + nums[j] == target, and false otherwise.
Important: Your solution must run in O(n) time.
This is similar to Two Sum, but you only need to return whether a pair exists (boolean), not the actual indices.
nums = [1, 5, 3, 7], target = 8truenums = [2, 4, 6], target = 5falsenums = [3, 3], target = 6true2 <= nums.length <= 10^5-10^9 <= nums[i] <= 10^9-10^9 <= target <= 10^9Expected time complexity: O(n)Run your code to see results
Use Cmd+Enter to run