By using this approach i'm getting only 3 pair pls help

static void targetSumTriplet(int[] arr, int target) {
int low = 0;
int high = arr.length - 1;
int mid = (low + high) / 2;

	while ((low <=  mid) && (low<=high) &&( mid <=  high)) {

		if (arr[low] + arr[mid] + arr[high] == target) {
			System.out.println(arr[low] + " " + arr[mid] + " and " + arr[high]);
			high--;
			mid++;
			
		} else if (arr[low] + arr[mid] + arr[high] > target) {
			mid--;
			high--;
		} else {
			high++;
		}

	}
}

hey @nigamshubham1998 Your code is going into an infinite loop
correct code :
https://ide.codingblocks.com/s/260180

why are you taking low = i+1 , why not low=0;
wy are you taking sum variable ??

@nigamshubham1998 These two lines are not required
int low = 0;
int high = arr.length - 1;
You can remove it

why are you taking low = i+1 , why not low=0;
wy are you taking sum variable ??

for (int i = 0; i < arr.length; i++) {
int j = i + 1;
int k = arr.length - 1;
int sum = target - arr[i];
while (j < k) {
if (sum > arr[k] + arr[j]) {
j++;
} else if (sum < arr[k] + arr[j]) {
k–;
} else {
System.out.println(arr[i] + ", " + arr[j] + " and " + arr[k]);
j++;

			}
		}

}
where is low = i+1 ??
sum variable store targer - arr[i]
without sum variable you can do it. no issue