LeetCode Çözümleri – 16. 3Sum Closest

LeetCode içerisinde bulunan “3Sum Closest” sorusunun açıklaması ve çözümü. Size verilen bir tam sayı dizisi ve “hedef” toplam için, sayı dizisi içerisindeki 3 sayının toplamı olarak bu “hedef” sayısına en yakın olanı bulmanız isteniyor.

► LeetCode 16. 3Sum Closest: https://leetcode.com/problems/3sum-closest/

► Problem açıklaması:

Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.

Example 1:

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

Output: 2

Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.