Find all triplets in an array that add up to a given sum - Brute Force Technique
Hello everyone, Welcome to Sprint Master! In this post, we are going to look at solving the following coding question "Find all triplets in an array that add up to a given sum" As you all know, a problem can be solved in multiple ways, and this particular question can be solved in 4 different ways. In today's post we will be looking at one of the ways to solve this question by using Brute-Force technique. In this approach, we will try to find all the triplets that are possible from the given array, and for each triplet we calculate the sum and check if that sum matches with the given sum. If the sum matches, then we have a triplet. I have a more elaborate discussion of this approach in the following video. You can also find the complete code snippet with which we can solve this problem down below. import java.util.Arrays; public class Solution1{ public static void main(String []args){ System.out.print...