Skip to content

Instantly share code, notes, and snippets.

@jkevintu
jkevintu / array-quadruplet.js
Created May 17, 2017 06:44
Array Quadruplet
var arr = [0, 0, 0, 1, 2, 5, 6, 7, 8, 9, 11, 16, 18, 19, 20, 21, 24, 25, 26, 28, 30, 32, 33, 35, 38, 43, 45, 46, 49, 50, 54, 55, 59, 63, 64, 65, 68, 69, 72, 75, 76, 79, 80, 81, 83, 86, 87, 88, 89, 90, 94, 96, 98, 99];
var s = 387;
// var arr = [5, 5, 5, 5];
// var s = 20;
console.log(findArrayQuadruplet(arr,s));
function findArrayQuadruplet(arr, sum) {
if (arr.length < 4) return [];
var new_arr = cleanArray(arr, sum);