Hello,
Welcome to Day 2 of DSA. We hope you were able to solve the Day 1 problem and allocate sufficient time for it. We have published one Youtube video explaining the thinking procedure of the Day 1 problem.
Check the Day 1 video solution here.
Now coming for Day 2,
The problem statement for Day 2 goes as follow,
Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]]
 such that i != j
, i != k
, and j != k
, and nums[i] + nums[j] + nums[k] == 0
.
Notice that the solution set must not contain duplicate triplets.
Example 1:
Input:
nums = [-1,0,1,2,-1,-4]
Output:
[[-1,-1,2],[-1,0,1]]
Example 2:
Input:
nums = []
Output:
[]
Example 3:
Input:
nums = [0]
Output:
[]
Hint: This problem can be solved with a similar approach to that of Day 1 using two pointers.
Instructions
Take a pen and paper don’t rush to google it.
Come up with a Naive solution.
Try to optimize the solution further.
Try and submit your code here.
Solution video will be out on the very next day ✌
If you have not downloaded our official android application(Early Access), download it from here.
Thank you for stopping by!