Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

3Sum (Medium 15)

Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.

Solution:

Click here Sort array. Iterate with three pointers, moving them if needed. Skip same elements. 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.