@adnen/twosum

1.0.5 • Public • Published

Two sum leetcode solution with o(n) time complexity package

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

Install

npm install @adnen/twosum

Test

npm run test

Usage

// TYPESCRIPT FILE 
import twoSum from '@adnen/twosum'


const nums   : number[]   = [1,2,7,11,15];
const target : number     = 9;

const result : number[][] = twosum(nums,target)

console.log(result)
//  [[1,2]]
// JAVASCRIPT FILE 
import twoSum from '@adnen/twosum'


const nums   = [1,2,7,11,15];
const target = 9;

const result = twosum(nums,target)

console.log(result)
//  [[1,2]]

Package Sidebar

Install

npm i @adnen/twosum

Weekly Downloads

1

Version

1.0.5

License

MIT

Unpacked Size

4.51 kB

Total Files

10

Last publish

Collaborators

  • rebai