Comparing version 0.1.32 to 0.1.33
@@ -9,3 +9,3 @@ import { PriorityQueue } from './priorityQueue'; | ||
import { Matrix } from './matrix'; | ||
import { lengthOfLongestSubstring, backspaceCompare, isPalindrome, strip } from './string'; | ||
export { PriorityQueue, BinaryTree, BinaryNode, BST, quickSort, pivot, quickSelect, quickSelectPivot, binarySearch, binarySearchRange, searchRange, Graph, Dijkstra, Matrix, lengthOfLongestSubstring, backspaceCompare, isPalindrome, strip, }; | ||
import { lengthOfLongestSubstring, backspaceCompare, isPalindrome, strip, isSubPalindrome } from './string'; | ||
export { PriorityQueue, BinaryTree, BinaryNode, BST, quickSort, pivot, quickSelect, quickSelectPivot, binarySearch, binarySearchRange, searchRange, Graph, Dijkstra, Matrix, lengthOfLongestSubstring, backspaceCompare, isPalindrome, strip, isSubPalindrome, }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.strip = exports.isPalindrome = exports.backspaceCompare = 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.isSubPalindrome = exports.strip = exports.isPalindrome = exports.backspaceCompare = 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"); | ||
@@ -31,1 +31,2 @@ Object.defineProperty(exports, "PriorityQueue", { enumerable: true, get: function () { return priorityQueue_1.PriorityQueue; } }); | ||
Object.defineProperty(exports, "strip", { enumerable: true, get: function () { return string_1.strip; } }); | ||
Object.defineProperty(exports, "isSubPalindrome", { enumerable: true, get: function () { return string_1.isSubPalindrome; } }); |
@@ -5,1 +5,2 @@ export declare function lengthOfLongestSubstring(s: string): number; | ||
export declare function isPalindrome(str: string): boolean; | ||
export declare function isSubPalindrome(str: string): boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isPalindrome = exports.strip = exports.backspaceCompare = exports.lengthOfLongestSubstring = void 0; | ||
exports.isSubPalindrome = exports.isPalindrome = exports.strip = exports.backspaceCompare = exports.lengthOfLongestSubstring = void 0; | ||
function lengthOfLongestSubstring(s) { | ||
@@ -76,1 +76,32 @@ if (s.length === 0) { | ||
exports.isPalindrome = isPalindrome; | ||
function _isPalindrome(str, start, end) { | ||
var p1 = start; | ||
var p2 = end; | ||
while (p1 < p2) { | ||
if (str[p1] !== str[p2]) { | ||
return false; | ||
} | ||
p1 += 1; | ||
p2 -= 1; | ||
} | ||
return true; | ||
} | ||
function isSubPalindrome(str) { | ||
var s = strip(str); | ||
var p1 = 0; | ||
var p2 = s.length - 1; | ||
while (p1 < p2) { | ||
if (s[p1] !== s[p2]) { | ||
if (_isPalindrome(s, p1 + 1, p2) || _isPalindrome(s, p1, p2 - 1)) { | ||
return true; | ||
} | ||
else { | ||
return false; | ||
} | ||
} | ||
p1 += 1; | ||
p2 -= 1; | ||
} | ||
return true; | ||
} | ||
exports.isSubPalindrome = isSubPalindrome; |
{ | ||
"name": "flex-algo", | ||
"version": "0.1.32", | ||
"version": "0.1.33", | ||
"description": "\"SDK for commonly used data structure and algorithms\"", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
44726
1233