Tags: programming leetcode code
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.1
Brute force algorithm
It has problems like it doesn’t account for duplicate elements. Also it has complexity of @L O(n3) @L which is not optimal.
More efficient solution
Using two pointer solution, we can acheive @L O(n2) @L time complexity.
comments powered by