Posted on by Kalkicode

Find a triplet from three linked lists with given sum

Find a pair with the given sum in three unsorted linked list. This pair must contain at least one element of all linked lists.

``````Example
----------
List  A    5 → 2 → -2 → 1 → 3 → 6 → NULL
List  B   -1 → 2 → 5 → 4 → 9 → -9 → NULL
List  C    1 → 2 → 8 → 4 → 3 → 6 → NULL
-----------------------------------------
Sum : 22

List  A    5 → 2 → -2 → 1 → 3 → 6 → NULL
↑
List  B   -1 → 2 → 5 → 4 → 9 → -9 → NULL
↑
List  C    1 → 2 → 8 → 4 → 3 → 6 → NULL
↑
Triplet :  (5,9,8)
``````

We can solve this problem by traversal of the linked list. Print a valid message when the valid list does not contain totals. Here given code implementation process.

``````/*
C program for
Find a triplet from three linked lists with given sum
*/
#include <stdio.h>
#include <stdlib.h>

{
int data;
};
struct SingleLL
{
};
// Returns the new linked list
{
// Create memory of head and tail Nodes
struct SingleLL *sll =
(struct SingleLL *) malloc(sizeof(struct SingleLL));
if (sll == NULL)
{
printf("Memory overflow\n");
}
else
{
}
return sll;
}
void addNode(struct SingleLL *sll, int data)
{
// Create dynamic node
if (node == NULL)
{
return;
}
else
{
// Set initial node value
node->data = data;
node->next = NULL;
}
{
}
else
{
sll->tail->next = node;
}
sll->tail = node;
}
{
if (node == NULL)
{
return;
}
while (temp != NULL)
{
printf(" %d →", temp->data);
// Visit to next node
temp = temp->next;
}
printf(" NULL\n");
}
{
if (l1 == NULL || l2 == NULL || l3 == NULL)
{
printf(" Given Sum triplet not exist [Case Empty List]\n");
return;
}
printf("\n Given Lists \n");
display(l1);
display(l2);
display(l3);
printf(" Sum : %d \n", k);
while (t1 != NULL)
{
while (t2 != NULL)
{
while (t3 != NULL)
{
if (t1->data + t2->data + t3->data == k)
{
printf(" Triplet :  (%d,%d,%d)",
t1->data, t2->data, t3->data);
return;
}
// Visit to next node
t3 = t3->next;
}
// Visit to next node
t2 = t2->next;
t3 = l3;
}
// Visit to next node
t1 = t1->next;
t2 = l2;
}
}
int main(int argc, char
const *argv[])
{
//  5 → 2 → -2 → 1 → 3 → 6 → NULL
//  -1 → 2 → 5 → 4 → 9 → -9 → NULL
//  1 → 2 → 8 → 4 → 3 → 6 → NULL
int k = 22;
// Test
return 0;
}``````

Output

`````` Given Lists
5 → 2 → -2 → 1 → 3 → 6 → NULL
-1 → 2 → 5 → 4 → 9 → -9 → NULL
1 → 2 → 8 → 4 → 3 → 6 → NULL
Sum : 22
Triplet :  (5,9,8)``````
``````/*
Java program for
Find a triplet from three linked lists with given sum
*/
{
public int data;
{
this.data = data;
this.next = null;
}
}
public class SingleLL
{
public SingleLL()
{
this.tail = null;
}
{
{
}
else
{
// Append the node at last position
this.tail.next = node;
}
this.tail = node;
}
public void display()
{
{
return;
}
while (temp != null)
{
System.out.print(" " + temp.data + " →");
// Visit to next node
temp = temp.next;
}
System.out.print(" NULL\n");
}
public void tripletOfSumK( SingleLL l2, SingleLL l3, int k)
{
{
//  [Case Empty List]
System.out.print(" Given Sum triplet not exist\n");
return;
}
System.out.print("\n Given Lists \n");
this.display();
l2.display();
l3.display();
System.out.print(" Sum : " + k + " \n");
while (t1 != null)
{
while (t2 != null)
{
while (t3 != null)
{
if (t1.data + t2.data + t3.data == k)
{
System.out.print(" Triplet : (" +
t1.data + "," + t2.data + "," + t3.data + ")");
return;
}
// Visit to next node
t3 = t3.next;
}
// Visit to next node
t2 = t2.next;
}
// Visit to next node
t1 = t1.next;
}
System.out.print(" Triplet of sum " + k + " not found \n");
}
public static void main(String[] args)
{
SingleLL sll1 = new SingleLL();
SingleLL sll2 = new SingleLL();
SingleLL sll3 = new SingleLL();

//  5 → 2 → -2 → 1 → 3 → 6 → NULL
//  -1 → 2 → 5 → 4 → 9 → -9 → NULL
//  1 → 2 → 8 → 4 → 3 → 6 → NULL
int k = 22;
// Test
sll1.tripletOfSumK(sll2, sll3, k);
}
}``````

Output

`````` Given Lists
5 → 2 → -2 → 1 → 3 → 6 → NULL
-1 → 2 → 5 → 4 → 9 → -9 → NULL
1 → 2 → 8 → 4 → 3 → 6 → NULL
Sum : 22
Triplet : (5,9,8)``````
``````// Include header file
#include <iostream>
using namespace std;
/*
C++ program for
Find a triplet from three linked lists with given sum
*/
{
public:
int data;
{
this->data = data;
this->next = NULL;
}
};
class SingleLL
{
public:
SingleLL()
{
this->tail = NULL;
}
{
{
}
else
{
// Append the node at last position
this->tail->next = node;
}
this->tail = node;
}
void display()
{
{
return;
}
while (temp != NULL)
{
cout << " " << temp->data << " →";
// Visit to next node
temp = temp->next;
}
cout << " NULL\n";
}
void tripletOfSumK(SingleLL *l2,
SingleLL *l3,
int k)
{
{
//  [Case Empty List]
cout << " Given Sum triplet not exist\n";
return;
}
cout << "\n Given Lists \n";
this->display();
l2->display();
l3->display();
cout << " Sum : " << k << " \n";
while (t1 != NULL)
{
while (t2 != NULL)
{
while (t3 != NULL)
{
if (t1->data + t2->data + t3->data == k)
{
cout << " Triplet : ("
<< t1->data << ","
<< t2->data << ","
<< t3->data << ")";
return;
}
// Visit to next node
t3 = t3->next;
}
// Visit to next node
t2 = t2->next;
}
// Visit to next node
t1 = t1->next;
}
cout << " Triplet of sum " << k << " not found \n";
}
};
int main()
{
SingleLL *sll1 = new SingleLL();
SingleLL *sll2 = new SingleLL();
SingleLL *sll3 = new SingleLL();
//  5 → 2 → -2 → 1 → 3 → 6 → NULL
//  -1 → 2 → 5 → 4 → 9 → -9 → NULL
//  1 → 2 → 8 → 4 → 3 → 6 → NULL
int k = 22;
// Test
sll1->tripletOfSumK(sll2, sll3, k);
return 0;
}``````

Output

`````` Given Lists
5 → 2 → -2 → 1 → 3 → 6 → NULL
-1 → 2 → 5 → 4 → 9 → -9 → NULL
1 → 2 → 8 → 4 → 3 → 6 → NULL
Sum : 22
Triplet : (5,9,8)``````
``````// Include namespace system
using System;
/*
Csharp program for
Find a triplet from three linked lists with given sum
*/
{
public int data;
{
this.data = data;
this.next = null;
}
}
public class SingleLL
{
public SingleLL()
{
this.tail = null;
}
{
{
}
else
{
// Append the node at last position
this.tail.next = node;
}
this.tail = node;
}
public void display()
{
{
return;
}
while (temp != null)
{
Console.Write(" " + temp.data + " →");
// Visit to next node
temp = temp.next;
}
Console.Write(" NULL\n");
}
public void tripletOfSumK(SingleLL l2, SingleLL l3, int k)
{
{
//  [Case Empty List]
Console.Write(" Given Sum triplet not exist\n");
return;
}
Console.Write("\n Given Lists \n");
this.display();
l2.display();
l3.display();
Console.Write(" Sum : " + k + " \n");
while (t1 != null)
{
while (t2 != null)
{
while (t3 != null)
{
if (t1.data + t2.data + t3.data == k)
{
Console.Write(" Triplet : (" +
t1.data + "," +
t2.data + "," +
t3.data + ")");
return;
}
// Visit to next node
t3 = t3.next;
}
// Visit to next node
t2 = t2.next;
}
// Visit to next node
t1 = t1.next;
}
Console.Write(" Triplet of sum " + k + " not found \n");
}
public static void Main(String[] args)
{
SingleLL sll1 = new SingleLL();
SingleLL sll2 = new SingleLL();
SingleLL sll3 = new SingleLL();
//  5 → 2 → -2 → 1 → 3 → 6 → NULL
//  -1 → 2 → 5 → 4 → 9 → -9 → NULL
//  1 → 2 → 8 → 4 → 3 → 6 → NULL
int k = 22;
// Test
sll1.tripletOfSumK(sll2, sll3, k);
}
}``````

Output

`````` Given Lists
5 → 2 → -2 → 1 → 3 → 6 → NULL
-1 → 2 → 5 → 4 → 9 → -9 → NULL
1 → 2 → 8 → 4 → 3 → 6 → NULL
Sum : 22
Triplet : (5,9,8)``````
``````package main
import "fmt"
/*
Go program for
Find a triplet from three linked lists with given sum
*/
data int
}
me.data = data
me.next = nil
return me
}
type SingleLL struct {
}
func getSingleLL() * SingleLL {
var me *SingleLL = &SingleLL {}
me.tail = nil
return me
}
} else {
// Append the node at last position
this.tail.next = node
}
this.tail = node
}
func(this SingleLL) display() {
return
}
for (temp != nil) {
fmt.Print(" ", temp.data, " →")
// Visit to next node
temp = temp.next
}
fmt.Print(" NULL\n")
}
func(this SingleLL) tripletOfSumK(l2 * SingleLL,
l3 * SingleLL, k int) {
//  [Case Empty List]
fmt.Print(" Given Sum triplet not exist\n")
return
}
fmt.Print("\n Given Lists \n")
this.display()
l2.display()
l3.display()
fmt.Print(" Sum : ", k, " \n")
for (t1 != nil) {
for (t2 != nil) {
for (t3 != nil) {
if t1.data + t2.data + t3.data == k {
fmt.Print(" Triplet : (",
t1.data, ",",
t2.data, ",",
t3.data, ")")
return
}
// Visit to next node
t3 = t3.next
}
// Visit to next node
t2 = t2.next
}
// Visit to next node
t1 = t1.next
}
}
func main() {
var sll1 * SingleLL = getSingleLL()
var sll2 * SingleLL = getSingleLL()
var sll3 * SingleLL = getSingleLL()
//  5 → 2 → -2 → 1 → 3 → 6 → NULL
//  -1 → 2 → 5 → 4 → 9 → -9 → NULL
//  1 → 2 → 8 → 4 → 3 → 6 → NULL
var k int = 22
// Test
sll1.tripletOfSumK(sll2, sll3, k)
}``````

Output

`````` Given Lists
5 → 2 → -2 → 1 → 3 → 6 → NULL
-1 → 2 → 5 → 4 → 9 → -9 → NULL
1 → 2 → 8 → 4 → 3 → 6 → NULL
Sum : 22
Triplet : (5,9,8)``````
``````<?php
/*
Php program for
Find a triplet from three linked lists with given sum
*/
{
public \$data;
public \$next;
public	function __construct(\$data)
{
\$this->data = \$data;
\$this->next = NULL;
}
}
class SingleLL
{
public \$tail;
public	function __construct()
{
\$this->tail = NULL;
}
{
{
}
else
{
// Append the node at last position
\$this->tail->next = \$node;
}
\$this->tail = \$node;
}
public	function display()
{
{
return;
}
while (\$temp != NULL)
{
echo(" ".\$temp->data.
" →");
// Visit to next node
\$temp = \$temp->next;
}
echo(" NULL\n");
}
public	function tripletOfSumK(\$l2, \$l3, \$k)
{
{
//  [Case Empty List]
echo(" Given Sum triplet not exist\n");
return;
}
echo("\n Given Lists \n");
\$this->display();
\$l2->display();
\$l3->display();
echo(" Sum : ".\$k.
" \n");
while (\$t1 != NULL)
{
while (\$t2 != NULL)
{
while (\$t3 != NULL)
{
if (\$t1->data + \$t2->data + \$t3->data == \$k)
{
echo(" Triplet : (".\$t1->data.
",".\$t2->data.
",".\$t3->data.
")");
return;
}
// Visit to next node
\$t3 = \$t3->next;
}
// Visit to next node
\$t2 = \$t2->next;
}
// Visit to next node
\$t1 = \$t1->next;
}
echo(" Triplet of sum ".\$k.
}
}

function main()
{
\$sll1 = new SingleLL();
\$sll2 = new SingleLL();
\$sll3 = new SingleLL();
//  5 → 2 → -2 → 1 → 3 → 6 → NULL
//  -1 → 2 → 5 → 4 → 9 → -9 → NULL
//  1 → 2 → 8 → 4 → 3 → 6 → NULL
\$k = 22;
// Test
\$sll1->tripletOfSumK(\$sll2, \$sll3, \$k);
}
main();``````

Output

`````` Given Lists
5 → 2 → -2 → 1 → 3 → 6 → NULL
-1 → 2 → 5 → 4 → 9 → -9 → NULL
1 → 2 → 8 → 4 → 3 → 6 → NULL
Sum : 22
Triplet : (5,9,8)``````
``````/*
Node JS program for
Find a triplet from three linked lists with given sum
*/
{
constructor(data)
{
this.data = data;
this.next = null;
}
}
class SingleLL
{
constructor()
{
this.tail = null;
}
{
{
}
else
{
// Append the node at last position
this.tail.next = node;
}
this.tail = node;
}
display()
{
{
return;
}
while (temp != null)
{
process.stdout.write(" " + temp.data + " →");
// Visit to next node
temp = temp.next;
}
process.stdout.write(" NULL\n");
}
tripletOfSumK(l2, l3, k)
{
{
//  [Case Empty List]
process.stdout.write(" Given Sum triplet not exist\n");
return;
}
process.stdout.write("\n Given Lists \n");
this.display();
l2.display();
l3.display();
process.stdout.write(" Sum : " + k + " \n");
while (t1 != null)
{
while (t2 != null)
{
while (t3 != null)
{
if (t1.data + t2.data + t3.data == k)
{
process.stdout.write(" Triplet : (" +
t1.data + "," +
t2.data + "," +
t3.data + ")");
return;
}
// Visit to next node
t3 = t3.next;
}
// Visit to next node
t2 = t2.next;
}
// Visit to next node
t1 = t1.next;
}
process.stdout.write(" Triplet of sum " + k + " not found \n");
}
}

function main()
{
var sll1 = new SingleLL();
var sll2 = new SingleLL();
var sll3 = new SingleLL();
//  5 → 2 → -2 → 1 → 3 → 6 → NULL
//  -1 → 2 → 5 → 4 → 9 → -9 → NULL
//  1 → 2 → 8 → 4 → 3 → 6 → NULL
var k = 22;
// Test
sll1.tripletOfSumK(sll2, sll3, k);
}
main();``````

Output

`````` Given Lists
5 → 2 → -2 → 1 → 3 → 6 → NULL
-1 → 2 → 5 → 4 → 9 → -9 → NULL
1 → 2 → 8 → 4 → 3 → 6 → NULL
Sum : 22
Triplet : (5,9,8)``````
``````#    Python 3 program for
#    Find a triplet from three linked lists with given sum

def __init__(self, data) :
self.data = data
self.next = None

class SingleLL :
def __init__(self) :
self.tail = None

else :
#  Append the node at last position
self.tail.next = node

self.tail = node

def display(self) :
return

while (temp != None) :
print("", temp.data ,"→", end = "")
#  Visit to next node
temp = temp.next

print(" NULL")

def tripletOfSumK(self, l2, l3, k) :
#   [Case Empty List]
print(" Given Sum triplet not exist")
return

print("\n Given Lists ")
self.display()
l2.display()
l3.display()
print(" Sum : ", k ," ")
while (t1 != None) :
while (t2 != None) :
while (t3 != None) :
if (t1.data + t2.data + t3.data == k) :
print(" Triplet : (", t1.data ,",",
t2.data ,",",
t3.data ,")",
end = "")
return

#  Visit to next node
t3 = t3.next

#  Visit to next node
t2 = t2.next

#  Visit to next node
t1 = t1.next

def main() :
sll1 = SingleLL()
sll2 = SingleLL()
sll3 = SingleLL()
#   5 → 2 → -2 → 1 → 3 → 6 → NULL
#   -1 → 2 → 5 → 4 → 9 → -9 → NULL
#   1 → 2 → 8 → 4 → 3 → 6 → NULL
k = 22
#  Test
sll1.tripletOfSumK(sll2, sll3, k)

if __name__ == "__main__": main()``````

Output

`````` Given Lists
5 → 2 → -2 → 1 → 3 → 6 → NULL
-1 → 2 → 5 → 4 → 9 → -9 → NULL
1 → 2 → 8 → 4 → 3 → 6 → NULL
Sum :  22
Triplet : ( 5 , 9 , 8 )``````
``````#    Ruby program for
#    Find a triplet from three linked lists with given sum

attr_accessor :data, :next
def initialize(data)
self.data = data
self.next = nil
end

end

class SingleLL
# Define the accessor and reader of class SingleLL
def initialize()
self.tail = nil
end

else

#  Append the node at last position
self.tail.next = node
end

self.tail = node
end

def display()
return
end

while (temp != nil)
print(" ", temp.data ," →")
#  Visit to next node
temp = temp.next
end

print(" NULL\n")
end

def tripletOfSumK(l2, l3, k)
#   [Case Empty List]
print(" Given Sum triplet not exist\n")
return
end

print("\n Given Lists \n")
self.display()
l2.display()
l3.display()
print(" Sum : ", k ," \n")
while (t1 != nil)
while (t2 != nil)
while (t3 != nil)
if (t1.data + t2.data + t3.data == k)
print(" Triplet : (",
t1.data ,",",
t2.data ,",",
t3.data ,")")
return
end

#  Visit to next node
t3 = t3.next
end

#  Visit to next node
t2 = t2.next
end

#  Visit to next node
t1 = t1.next
end

end

end

def main()
sll1 = SingleLL.new()
sll2 = SingleLL.new()
sll3 = SingleLL.new()
#   5 → 2 → -2 → 1 → 3 → 6 → NULL
#   -1 → 2 → 5 → 4 → 9 → -9 → NULL
#   1 → 2 → 8 → 4 → 3 → 6 → NULL
k = 22
#  Test
sll1.tripletOfSumK(sll2, sll3, k)
end

main()``````

Output

`````` Given Lists
5 → 2 → -2 → 1 → 3 → 6 → NULL
-1 → 2 → 5 → 4 → 9 → -9 → NULL
1 → 2 → 8 → 4 → 3 → 6 → NULL
Sum : 22
Triplet : (5,9,8)``````
``````/*
Scala program for
Find a triplet from three linked lists with given sum
*/
{
def this(data: Int)
{
this(data,null);
}
}
{
def this()
{
this(null,null);
}
def addNode(data: Int): Unit = {
{
}
else
{
// Append the node at last position
this.tail.next = node;
}
this.tail = node;
}
def display(): Unit = {
{
return;
}
while (temp != null)
{
print(" " + temp.data + " →");
// Visit to next node
temp = temp.next;
}
print(" NULL\n");
}
def tripletOfSumK(l2: SingleLL, l3: SingleLL, k: Int): Unit = {
{
//  [Case Empty List]
print(" Given Sum triplet not exist\n");
return;
}
print("\n Given Lists \n");
this.display();
l2.display();
l3.display();
print(" Sum : " + k + " \n");
while (t1 != null)
{
while (t2 != null)
{
while (t3 != null)
{
if (t1.data + t2.data + t3.data == k)
{
print(" Triplet : (" +
t1.data + "," +
t2.data + "," +
t3.data + ")");
return;
}
// Visit to next node
t3 = t3.next;
}
// Visit to next node
t2 = t2.next;
}
// Visit to next node
t1 = t1.next;
}
print(" Triplet of sum " + k + " not found \n");
}
}
object Main
{
def main(args: Array[String]): Unit = {
var sll1: SingleLL = new SingleLL();
var sll2: SingleLL = new SingleLL();
var sll3: SingleLL = new SingleLL();
//  5 → 2 → -2 → 1 → 3 → 6 → NULL
//  -1 → 2 → 5 → 4 → 9 → -9 → NULL
//  1 → 2 → 8 → 4 → 3 → 6 → NULL
var k: Int = 22;
// Test
sll1.tripletOfSumK(sll2, sll3, k);
}
}``````

Output

`````` Given Lists
5 → 2 → -2 → 1 → 3 → 6 → NULL
-1 → 2 → 5 → 4 → 9 → -9 → NULL
1 → 2 → 8 → 4 → 3 → 6 → NULL
Sum : 22
Triplet : (5,9,8)``````
``````/*
Swift 4 program for
Find a triplet from three linked lists with given sum
*/
{
var data: Int;
init(_ data: Int)
{
self.data = data;
self.next = nil;
}
}
class SingleLL
{
init()
{
self.tail = nil;
}
{
{
}
else
{
// Append the node at last position
self.tail!.next = node;
}
self.tail = node;
}
func display()
{
{
return;
}
while (temp  != nil)
{
print("", temp!.data ,"→", terminator: "");
// Visit to next node
temp = temp!.next;
}
print(" NULL");
}
func tripletOfSumK(_ l2: SingleLL? , _ l3 : SingleLL? , _ k : Int)
{
{
//  [Case Empty List]
print(" Given Sum triplet not exist");
return;
}
print("\n Given Lists ");
self.display();
l2!.display();
l3!.display();
print(" Sum : ", k ," ");
while (t1  != nil)
{
while (t2  != nil)
{
while (t3  != nil)
{
if (t1!.data + t2!.data + t3!.data == k)
{
print(" Triplet : (",
t1!.data ,",",
t2!.data ,",",
t3!.data ,")", terminator: "");
return;
}
// Visit to next node
t3 = t3!.next;
}
// Visit to next node
t2 = t2!.next;
}
// Visit to next node
t1 = t1!.next;
}
}
}
func main()
{
let sll1: SingleLL = SingleLL();
let sll2: SingleLL = SingleLL();
let sll3: SingleLL = SingleLL();
//  5 → 2 → -2 → 1 → 3 → 6 → NULL
//  -1 → 2 → 5 → 4 → 9 → -9 → NULL
//  1 → 2 → 8 → 4 → 3 → 6 → NULL
let k: Int = 22;
// Test
sll1.tripletOfSumK(sll2, sll3, k);
}
main();``````

Output

`````` Given Lists
5 → 2 → -2 → 1 → 3 → 6 → NULL
-1 → 2 → 5 → 4 → 9 → -9 → NULL
1 → 2 → 8 → 4 → 3 → 6 → NULL
Sum :  22
Triplet : ( 5 , 9 , 8 )``````
``````/*
Kotlin program for
Find a triplet from three linked lists with given sum
*/
{
var data: Int;
constructor(data: Int)
{
this.data = data;
this.next = null;
}
}
class SingleLL
{
constructor()
{
this.tail = null;
}
{
{
}
else
{
// Append the node at last position
this.tail?.next = node;
}
this.tail = node;
}
fun display(): Unit
{
{
return;
}
while (temp != null)
{
print(" " + temp.data + " →");
// Visit to next node
temp = temp.next;
}
print(" NULL\n");
}
fun tripletOfSumK(l2: SingleLL, l3 : SingleLL, k : Int): Unit
{
{
//  [Case Empty List]
print(" Given Sum triplet not exist\n");
return;
}
print("\n Given Lists \n");
this.display();
l2.display();
l3.display();
print(" Sum : " + k + " \n");
while (t1 != null)
{
while (t2 != null)
{
while (t3 != null)
{
if (t1.data + t2.data + t3.data == k)
{
print(" Triplet : (" +
t1.data + "," + t2.data + "," +
t3.data + ")");
return;
}
// Visit to next node
t3 = t3.next;
}
// Visit to next node
t2 = t2.next;
}
// Visit to next node
t1 = t1.next;
}
print(" Triplet of sum " + k + " not found \n");
}
}
fun main(args: Array < String > ): Unit
{
val sll1: SingleLL = SingleLL();
val sll2: SingleLL = SingleLL();
val sll3: SingleLL = SingleLL();
//  5 → 2 → -2 → 1 → 3 → 6 → NULL
//  -1 → 2 → 5 → 4 → 9 → -9 → NULL
//  1 → 2 → 8 → 4 → 3 → 6 → NULL
val k: Int = 22;
// Test
sll1.tripletOfSumK(sll2, sll3, k);
}``````

Output

`````` Given Lists
5 → 2 → -2 → 1 → 3 → 6 → NULL
-1 → 2 → 5 → 4 → 9 → -9 → NULL
1 → 2 → 8 → 4 → 3 → 6 → NULL
Sum : 22
Triplet : (5,9,8)``````

Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

Categories
Relative Post