threesum

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

README

NAME

threesum - sum of triplets

PROBLEM

Given an array of numbers, find unique triplets that sum up to zero. Unique means that any permutation of numbers in the triplet is considered the same triplet, e.g. [1, 2, 3] and [2, 1, 3] are the same triplets.

EXAMPLE

  • Input: [-2, -3, 5]
  • Output: [-2, -3, 5]

SEE ALSO

Solution

Documentation

Overview

Example
package main

import (
	"fmt"

	"github.com/skhal/lab/iq/2/threesum"
)

func main() {
	triplets := threesum.Find([]int{-2, -3, 5})
	for _, triplet := range triplets {
		fmt.Println(triplet)
	}
}
Output:
[-3 -2 5]

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Triplet

type Triplet [3]int

func Find

func Find(nn []int) []*Triplet

func FindWithOptimizations

func FindWithOptimizations(nn []int) []*Triplet

func (*Triplet) String

func (t *Triplet) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL