Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

3Sum Closest (Medium 16)

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.

Solution:

Click here Sort array. Iterate with three pointers, moving them if needed. O(n^2) time, O(n) space if allocating new array, O(1) space if not allocating.



Installation

Run make to run python and Swift files.