DSAMaster Logo
DSAMaster
BackhardTwo Pointers

Triplet Sum With Middle Element Constraint

Problem Description

You are given an array of integers numbers and a target sum target. Find all unique triplets in the array that add up to the target sum, where the middle element of the triplet is at most the sum of the two other elements.

Example 1
Input
{"numbers":[12345],"target":6}
Output
[[123]]

Explanation: The triplet [1,2,3] is a valid solution because 1 + 2 + 3 = 6 and 2 <= 1 + 3.

Constraints

  • All elements in the array will be unique.
  • The array will have at least two elements.
  • The target sum will be greater than any element in the array.
00:00
Loading...

Sign in to Solve

Access the full code editor, ThinkBuddy AI hints, and track your progress.

Sign in Free
Test Cases & Output
Enter test input here...
Click "Run Code" to execute