Skip to content

Instantly share code, notes, and snippets.

View pulkit-singh-shipsy's full-sized avatar

Pulkit Singh pulkit-singh-shipsy

View GitHub Profile
@Kamilczak020
Kamilczak020 / Boyer-Moore.js
Created October 16, 2017 21:58
Boyer Moore string search algorithm implementation in Javascript
/**
* Returns the index of the first occurence of given string in the phrase
* In case of no match, returns -1
*
* @param text string to be searched
* @param pattern string to be found in the text
*/
export function boyerMooreSearch(text: string, pattern: string): number {
// Handle edge case