Skip to content

devslopes/algo-1-closest-sum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Closest Problem

Problem Statement

You are given an array of integers, nums, and another integer, target. Your task is to identify three distinct elements from the array such that their combined sum is as close as possible to the value of target.

Your solution should return this closest possible sum of the three elements.

You can assume there is always exactly one unique combination that results in the closest sum.

Example 1

  • Input: nums = [-1, 2, 1, -4], target = 1
  • Output: 2
  • Explanation: The sum of the three numbers closest to 1 is 2, achieved by the combination (-1 + 2 + 1 = 2).

Example 2

  • Input: nums = [0, 0, 0], target = 1
  • Output: 0
  • Explanation: The closest sum is 0, since 0 + 0 + 0 = 0.

Project Setup

To get started with solving this problem, follow these steps:

1. Clone the Repository

git clone https://github.com/devslopes/algo-1-closest-sum.git
cd closest

2. Install Dependencies

npm install

3. Run the Tests

npm test

4. Solve the Problem!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published