Two Pointers: 3 Sum Zero
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note:
Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c)
The solution set must not contain duplicate triplets.For example, given array
S = {-1 0 1 2 -1 -4}
,A solution set is:
(-1, 0, 1)
(-1, -1, 2)
Read complete question here — https://www.interviewbit.com/problems/min-steps-in-infinite-grid/
Asked in Facebook, Google.
Watch the complete video to understand the algorithm completely
Check out this easy code.
If you find this article helpful, give me a clap 👏.
Have any better solution? Share it in the comment section.
Check out Red Coder Publication for more solutions of InterviewBit, Leetcode, Codeforces, etc — Click here
Follow me for more articles 😃