VOOZH about

URL: https://www.geeksforgeeks.org/videos/problem-of-the-day-04112024-find-all-triplets-with-zero-sum/

⇱ PROBLEM OF THE DAY : 04/11/2024 | Find All Triplets with Zero Sum - GeeksforGeeks | Videos


November 13, 2024 |910 Views

PROBLEM OF THE DAY : 04/11/2024 | Find All Triplets with Zero Sum

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Yash Dwivedi We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Arrays but also build up problem-solving skills.

Given an array arr[], find all possible indices [i, j, k] of triplets [arr[i], arr[j], arr[k]] in the array whose sum is equal to zero. Return indices of triplets in any order and all the returned triplets indices should also be internally sorted, i.e., for any triplet indices [i, j, k], the condition i < j < k should hold.

Note: Try to solve this using the O(n2) approach.

Examples:

Input: arr[] = [0, -1, 2, -3, 1] Output: [[0, 1, 4], [2, 3, 4]] Explanation: Triplets with sum 0 are:
arr[0] + arr[1] + arr[4] = 0 + (-1) + 1 = 0 arr[2] + arr[3] + arr[4] = 2 + (-3) + 1 = 0

Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/find-all-triplets-with-zero-sum/1

Recommendations
2.0K Views | 23/04/2026...
Row with maximum number of 1s
3.5K Views | 10/01/2025...
Get level of a node in binary tree Iterative approach
27.4K Views | 10/01/2025...
Implement two stacks in an array
33.8K Views | 10/01/2025...
Longest Palindromic Subsequence
10.7K Views | 10/01/2025...
Maximum Sum Increasing Subsequence
17.9K Views | 10/01/2025...
Iterative Postorder Traversal
7.2K Views | 10/01/2025...
Sort a linked list of 0s, 1s and 2s
11.5K Views | 09/01/2025...
Segment Tree | Set 2 (Range Minimum Query)
16.7K Views | 09/01/2025...
Convert a given Binary Tree to Doubly Linked List | Set 3
10.2K Views | 08/01/2025...
SDE Sheet - Special Keyboard