# Sorting

## 3Sum LeetCode Solution | Easy Approach | C++, Java, Python

3Sum LeetCode | 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: [] …

## 4Sum LeetCode Solution | C++, Java, Python | Easy Approach

4Sum | Given an arrayÂ numsÂ ofÂ nÂ integers, returnÂ an array of all theÂ uniqueÂ quadrupletsÂ [nums[a], nums[b], nums[c], nums[d]]Â such that: 0 <= a, b, c, d < n a, b, c, and d are distinct. nums[a] + nums[b] + nums[c] + nums[d] == target You may return the answer in any order. Example 1: Input: nums = [1,0,-1,0,-2,2], target = 0 Output: [[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]] Example 2: Input: nums = …

## 3Sum Closest LeetCode Solution | C++, Java, Python | Easy Approach

3Sum Closest | Given an integer arrayÂ numsÂ of lengthÂ nÂ and an integerÂ target, find three integers inÂ numsÂ such that the sum is closest toÂ target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Example 1: Input: nums = [-1,2,1,-4], target = 1 Output: 2 Explanation: The sum that is closest to …