Find Triplet with Given Sum in an Array

Find triplet with given sum in an array.

Given an array of unsorted integers and a value k. Write a code to determine whether or not there exist three elements in array whose sum is equal to k.

Return true if triplet exist else return false.

For example:

Example 1:

Input: {1, 4, 45, 6, 10, 8} k = 13 Output: true (1, 4, 8)

Example 2:

Input: {2, 7, 4, 0, 9, 5, 1, 3} k = 6
Output: true {(2, 4, 0), (5, 1, 0), (1, 2, 3)}