2
* @param {number[]} digits5
var largestMultipleOfThree = function (digits) {7
digits.sort((l, r) => r - l);9
// what is the remainder of the total sum?10
const sumRemainder = digits.reduce((a, c) => a + c, 0) % 3;14
i = digits.length - 1;16
// try to find what is the smallest number that can be removed18
if ((digits[i] - sumRemainder) % 3 === 0) {25
// iterated the whole loop, couldn't find a single number to remove26
// remove everything but multiples of 327
digits = digits.filter((v) => v % 3 === 0);29
digits.splice(targetIndex, 1);33
return digits[0] === 0 ? "0" : digits.join("");