1.0.0 • Published 4 years ago

@windate3411/utils v1.0.0

Weekly downloads
2
License
ISC
Repository
-
Last release
4 years ago

GitHub issues

Descripition

This package contains vary of functions I found myself used quite often while dealing with leetcode questions. Feel free to let me know what's on your mind :D

Install

npm install @windate3411/utils

Basic Usages

const utils = require("@windate3411/utils")

uitls.isPrime(4);
//false

uitls.countElement([1,4,3,2,2,5,7,6])
//{ '1': 1, '2': 2,
    '3': 1, '4': 1, 
    '5': 1, '6': 1, 
    '7': 1 }

uitls.permutaion([1,2,3])
//[ [ 1, 2, 3 ],
  [ 1, 3, 2 ],
  [ 2, 1, 3 ],
  [ 2, 3, 1 ],
  [ 3, 1, 2 ],
  [ 3, 2, 1 ] ]

Table of contents

functiondescriptionparams typereturn data type
isPrime(num)check if num is a prime numbernumberboolean
countPrime(num)count how many prime numbers between 0 and numnumbernumber
countElement(arr)count elements in the array and return an objectarrayobject
combination(m,n)return the number of combinations given C(m,n)numbernumber
fraction(num)return the fraction of numnumbernumber
permutaion(arr)return the permutaions of given arrarrayarray
objectSort(obj)return sorted object alphabeticallyobjectobject

Author

Danny Wang