param { number [ ] } arr return { number [ ] } function SumThreeNumbers ( arr ) { const result = [ ] ; arr . sort ( ( a , b ) => a - b ) ; for ( let i = 0 ; i < arr . length ; i ++ ) { if ( i && arr [ i ] === arr [ i - 1 ] ) { continue ; } let left = i + 1 ; let right = arr . length - 1 ; while ( left < right ) { let sum = arr [ i ] + arr [ left ] + arr [ right ] ; if ( sum > 0 ) { right -- ; } else if ( sum < 0 ) { left ++ ; } else { result . push ( [ arr [ i ] , arr [ left ] , arr [ right ] ] ) ; left ++ ; right -- ; while ( arr [ left ] === arr [ left - 1 ] ) { left ++ ; } while ( arr [ right ] === arr [ right + 1 ] ) { right -- ; } } } } return result ; } export { SumThreeNumbers } ;