Google | Onsite | Two Sum - Closest to Target

33156
Feb 22, 2019
Sep 01, 2019

Given an int array nums and an int target. Find two integers in nums such that the sum is closest to target.

Example 1:

Input: nums = [1, 2, 3, 4, 5], target = 10
Output: [4, 5]

Example 2:

Input: nums= [-1, 2, 1, -4], target = 4
Output: [2, 1]

https://leetcode.com/problems/two-sum-less-than-k (premium)

Comments (22)