Raj shukla

Approach to solve leetcode question- 16 3Sum Closest

  1. This question is somewhat similar to previous question leetcode -15 3Sum with a small change.

2. In this solution , we will take each element of array nums , and then for each element we will take two elements ahead of that…

--

--

Approach to solve leetcode question-15 3Sum

We can get all combinations of 3 elements and see their sum is equal to 0 or not and return all combinations which sums to 0, but this approach will not be efficient.

Instead we will use following approach:

  1. we will sort the array…

--

--

--

--