Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flex-algo

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flex-algo - npm Package Compare versions

Comparing version 0.1.43 to 0.1.44

1

lib/array.d.ts
export declare function twoSum(nums: number[], target: number): number[];
export declare function maxArea(heights: number[]): number;
export declare function moveZeroes(nums: number[]): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.maxArea = exports.twoSum = void 0;
exports.moveZeroes = exports.maxArea = exports.twoSum = void 0;
function twoSum(nums, target) {

@@ -35,1 +35,15 @@ var map = {};

exports.maxArea = maxArea;
function moveZeroes(nums) {
var p = 0;
for (var i = 0; i < nums.length; i++) {
if (nums[i] !== 0) {
nums[p] = nums[i];
p += 1;
}
}
while (p < nums.length) {
nums[p] = 0;
p += 1;
}
}
exports.moveZeroes = moveZeroes;

6

lib/index.d.ts

@@ -9,4 +9,4 @@ import { PriorityQueue } from './priorityQueue';

import { Matrix } from './matrix';
import { lengthOfLongestSubstring, lengthOfLongestSubstringTwoDistinct, backspaceCompare, isPalindrome, strip, isSubPalindrome } from './string';
import { twoSum, maxArea } from './array';
import { lengthOfLongestSubstring, lengthOfLongestSubstringTwoDistinct, backspaceCompare, isPalindrome, strip, isSubPalindrome, hash, groupAnagrams, multiply } from './string';
import { twoSum, maxArea, moveZeroes } from './array';
import { isValidParentheses, minRemoveToMakeValid } from './stack';

@@ -17,2 +17,2 @@ import { StackQueue } from './stackQueue';

import { longestPalindrome, maxSubArray } from './dynamicProgramming';
export { PriorityQueue, BinaryTree, BinaryNode, BST, quickSort, pivot, quickSelect, quickSelectPivot, binarySearch, binarySearchRange, searchRange, Graph, Dijkstra, Matrix, lengthOfLongestSubstring, lengthOfLongestSubstringTwoDistinct, backspaceCompare, isPalindrome, strip, isSubPalindrome, longestPalindrome, maxSubArray, twoSum, maxArea, isValidParentheses, minRemoveToMakeValid, StackQueue, ValueType, LinkedList, };
export { PriorityQueue, BinaryTree, BinaryNode, BST, quickSort, pivot, quickSelect, quickSelectPivot, binarySearch, binarySearchRange, searchRange, Graph, Dijkstra, Matrix, lengthOfLongestSubstring, lengthOfLongestSubstringTwoDistinct, backspaceCompare, isPalindrome, strip, isSubPalindrome, longestPalindrome, hash, groupAnagrams, multiply, maxSubArray, twoSum, maxArea, moveZeroes, isValidParentheses, minRemoveToMakeValid, StackQueue, ValueType, LinkedList, };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LinkedList = exports.StackQueue = exports.minRemoveToMakeValid = exports.isValidParentheses = exports.maxArea = exports.twoSum = exports.maxSubArray = exports.longestPalindrome = exports.isSubPalindrome = exports.strip = exports.isPalindrome = exports.backspaceCompare = exports.lengthOfLongestSubstringTwoDistinct = exports.lengthOfLongestSubstring = exports.Matrix = exports.Dijkstra = exports.Graph = exports.searchRange = exports.binarySearchRange = exports.binarySearch = exports.quickSelectPivot = exports.quickSelect = exports.pivot = exports.quickSort = exports.BST = exports.BinaryNode = exports.BinaryTree = exports.PriorityQueue = void 0;
exports.LinkedList = exports.StackQueue = exports.minRemoveToMakeValid = exports.isValidParentheses = exports.moveZeroes = exports.maxArea = exports.twoSum = exports.maxSubArray = exports.multiply = exports.groupAnagrams = exports.hash = exports.longestPalindrome = exports.isSubPalindrome = exports.strip = exports.isPalindrome = exports.backspaceCompare = exports.lengthOfLongestSubstringTwoDistinct = exports.lengthOfLongestSubstring = exports.Matrix = exports.Dijkstra = exports.Graph = exports.searchRange = exports.binarySearchRange = exports.binarySearch = exports.quickSelectPivot = exports.quickSelect = exports.pivot = exports.quickSort = exports.BST = exports.BinaryNode = exports.BinaryTree = exports.PriorityQueue = void 0;
var priorityQueue_1 = require("./priorityQueue");

@@ -33,5 +33,9 @@ Object.defineProperty(exports, "PriorityQueue", { enumerable: true, get: function () { return priorityQueue_1.PriorityQueue; } });

Object.defineProperty(exports, "isSubPalindrome", { enumerable: true, get: function () { return string_1.isSubPalindrome; } });
Object.defineProperty(exports, "hash", { enumerable: true, get: function () { return string_1.hash; } });
Object.defineProperty(exports, "groupAnagrams", { enumerable: true, get: function () { return string_1.groupAnagrams; } });
Object.defineProperty(exports, "multiply", { enumerable: true, get: function () { return string_1.multiply; } });
var array_1 = require("./array");
Object.defineProperty(exports, "twoSum", { enumerable: true, get: function () { return array_1.twoSum; } });
Object.defineProperty(exports, "maxArea", { enumerable: true, get: function () { return array_1.maxArea; } });
Object.defineProperty(exports, "moveZeroes", { enumerable: true, get: function () { return array_1.moveZeroes; } });
var stack_1 = require("./stack");

@@ -38,0 +42,0 @@ Object.defineProperty(exports, "isValidParentheses", { enumerable: true, get: function () { return stack_1.isValidParentheses; } });

@@ -7,1 +7,7 @@ export declare function lengthOfLongestSubstring(s: string): number;

export declare function isSubPalindrome(str: string): boolean;
export declare function hash(str: string): string;
export declare function groupAnagrams(strs: string[]): {
map: Record<string, string[]>;
anagrams: string[][];
};
export declare function multiply(num1: string, num2: string): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSubPalindrome = exports.isPalindrome = exports.strip = exports.backspaceCompare = exports.lengthOfLongestSubstringTwoDistinct = exports.lengthOfLongestSubstring = void 0;
exports.multiply = exports.groupAnagrams = exports.hash = exports.isSubPalindrome = exports.isPalindrome = exports.strip = exports.backspaceCompare = exports.lengthOfLongestSubstringTwoDistinct = exports.lengthOfLongestSubstring = void 0;
function lengthOfLongestSubstring(s) {

@@ -142,1 +142,84 @@ if (s.length === 0) {

exports.isSubPalindrome = isSubPalindrome;
var ALPHABET_SIZE = 26;
var ALPHABET_TABLE = {
a: 0,
b: 1,
c: 2,
d: 3,
e: 4,
f: 5,
g: 6,
h: 7,
i: 8,
j: 9,
k: 10,
l: 11,
m: 12,
n: 13,
o: 14,
p: 15,
q: 16,
r: 17,
s: 18,
t: 19,
u: 20,
v: 21,
w: 22,
x: 23,
y: 24,
z: 25,
};
function hash(str) {
var arr = new Array(ALPHABET_SIZE).fill(0);
for (var i = 0; i < str.length; i++) {
arr[ALPHABET_TABLE[str[i]]] += 1;
}
return arr.join('#');
}
exports.hash = hash;
function groupAnagrams(strs) {
var anagrams = {};
for (var i = 0; i < strs.length; i++) {
var hashStr = hash(strs[i]);
if (anagrams[hashStr]) {
anagrams[hashStr].push(strs[i]);
}
else {
anagrams[hashStr] = [strs[i]];
}
}
return {
map: anagrams,
anagrams: Object.values(anagrams),
};
}
exports.groupAnagrams = groupAnagrams;
function multiply(num1, num2) {
var nums = new Array(num1.length + num2.length).fill(0);
for (var i = 0; i < num2.length; i++) {
var carry = 0;
var bottomIndex = num2.length - 1 - i;
for (var j = 0; j < num1.length; j++) {
var topIndex = num1.length - 1 - j;
var offset = i + j;
var result_1 = parseInt(num2[bottomIndex]) * parseInt(num1[topIndex]) + nums[offset] + carry;
carry = Math.trunc(result_1 / 10);
nums[offset] = result_1 % 10;
}
nums[i + num1.length] += carry;
}
var result = [];
// remove leading 0
var leading = 1;
for (var i = nums.length - 1; i >= 0; i--) {
if (nums[i] !== 0 && leading === 1) {
result.push(nums[i]);
leading = 0;
}
else if (leading === 0) {
result.push(nums[i]);
}
}
return result.join('');
}
exports.multiply = multiply;
{
"name": "flex-algo",
"version": "0.1.43",
"version": "0.1.44",
"description": "\"SDK for commonly used data structure and algorithms\"",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc