題庫
00:00

11. 3Sum Closest

中等雙指標AmazonGoogle

Given an integer array nums and an integer target, find three integers whose sum is closest to target.

Return the sum of the three integers. Each input has exactly one closest answer.

範例 1:

輸入: nums = [-1,2,1,-4], target = 1
輸出: 2

範例 2:

輸入: nums = [0,0,0], target = 1
輸出: 0

限制條件:

  • 3 <= nums.length <= 500
  • -1000 <= nums[i] <= 1000
核心程式碼模式
● 已自動儲存第 1 行,第 1 欄