diff --git "a/342円234円205円 Pattern 02: Two Pointers.md" "b/342円234円205円 Pattern 02: Two Pointers.md" index a2484e8..ef78236 100644 --- "a/342円234円205円 Pattern 02: Two Pointers.md" +++ "b/342円234円205円 Pattern 02: Two Pointers.md" @@ -220,21 +220,6 @@ To follow a similar approach, first, we will sort the array and then iterate thr Another difference from [Pair with Target Sum](#🌴-pair-with-target-sum-aka-"two-sum"-easy) is that we need to find all the unique triplets. To handle this, we have to skip any duplicate number. Since we will be sorting the array, so all the duplicate numbers will be next to each other and are easier to skip. ````js -function searchTriplets(arr) { - arr.sort((a, b) => a-b) - const triplets = []; - - for(i = 0; i< arr.length;i++) { - - if(i>0 && arr[i] === arr[i -1]){ - //skip the same element to avoid dupes - continue - } - searchPair(arr, -arr[i], i+1, triplets) - } - return triplets; -}; - function searchTriplets(arr) { arr.sort((a, b) => a -b) const triplets = []

AltStyle によって変換されたページ (->オリジナル) /