Skip to content

Instantly share code, notes, and snippets.

View DNature's full-sized avatar
🇳🇱
Building the FUTURE

Divine Hycenth DNature

🇳🇱
Building the FUTURE
View GitHub Profile
@DNature
DNature / LinkedList.js
Last active March 20, 2021 11:56
Javascript Linked List algorithm
function LinkedList(){
this.length = 0;
this.head = null
const Node = function(element) {
this.element = element
this.next = null
}
this.add = (element) => {
@DNature
DNature / hashTable.js
Created March 18, 2021 14:26
Hash Table (Hash Map) using Javascript
function HashTable(){
this.table = new Array(3)
this.itemsLength = 0
this.hashStringToInt = (str, tableSize) => {
let hash = 13
for (let i = 0; i < str.length; i++){
hash = (13 * hash * str.charCodeAt(i))
}
@DNature
DNature / matchinBrackets.js
Last active March 18, 2021 14:25
Parenthesis/Brackets Matching using Stack algorithm (Javascript)
function matchParenthesis(str){
const stack = []
const opening = /(\(|\{|\[)/
const closing = /(\)|\}|\])/
if(!str || !str.length) return undefined
for(let i = 0; i < str.length; i++){