mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-07 19:17:33 +08:00
fixed some spellings
This commit is contained in:
@ -11,7 +11,7 @@ function main () {
|
||||
Note:
|
||||
* While Solving the problem in given link below, don't use main() function.
|
||||
* Just use only the code inside main() function.
|
||||
* The purpose of using main() function here is to aviod global variables.
|
||||
* The purpose of using main() function here is to avoid global variables.
|
||||
|
||||
Link for the Problem: https://leetcode.com/problems/linked-list-cycle/
|
||||
*/
|
||||
|
@ -10,7 +10,7 @@ function main () {
|
||||
Note:
|
||||
* While Solving the problem in given link below, don't use main() function.
|
||||
* Just use only the code inside main() function.
|
||||
* The purpose of using main() function here is to aviod global variables.
|
||||
* The purpose of using main() function here is to avoid global variables.
|
||||
|
||||
Link for the Problem: https://leetcode.com/problems/rotate-list/
|
||||
*/
|
||||
|
@ -37,7 +37,7 @@ let utils;
|
||||
*/
|
||||
const AVLTree = (function () {
|
||||
function _avl (comp) {
|
||||
/** @public compartor function */
|
||||
/** @public comparator function */
|
||||
this._comp = undefined
|
||||
if (comp !== undefined) {
|
||||
this._comp = comp
|
||||
@ -119,7 +119,7 @@ const AVLTree = (function () {
|
||||
node._right = rightRotate(node._right)
|
||||
return leftRotate(node) // Right Left
|
||||
}
|
||||
return leftRotate(node) // Rigth Right
|
||||
return leftRotate(node) // Right Right
|
||||
}
|
||||
// implement avl tree insertion
|
||||
const insert = function (root, val, tree) {
|
||||
@ -202,7 +202,7 @@ const AVLTree = (function () {
|
||||
return true
|
||||
}
|
||||
/**
|
||||
* TO check is a particluar element exists or not
|
||||
* TO check is a particular element exists or not
|
||||
* @param {any} _val
|
||||
* @returns {Boolean} exists or not
|
||||
*/
|
||||
|
@ -14,7 +14,7 @@ function Trie () {
|
||||
this.root = new TrieNode(null, null)
|
||||
}
|
||||
|
||||
// Recursively finds the occurence of all words in a given node
|
||||
// Recursively finds the occurrence of all words in a given node
|
||||
Trie.findAllWords = function (root, word, output) {
|
||||
if (root === null) return
|
||||
if (root.count > 0) {
|
||||
@ -79,11 +79,11 @@ Trie.prototype.remove = function (word, count) {
|
||||
child = child.children[key]
|
||||
}
|
||||
|
||||
// Delete no of occurences specified
|
||||
// Delete no of occurrences specified
|
||||
if (child.count >= count) child.count -= count
|
||||
else child.count = 0
|
||||
|
||||
// If some occurences are left we dont delete it or else
|
||||
// If some occurrences are left we dont delete it or else
|
||||
// if the object forms some other objects prefix we dont delete it
|
||||
// For checking an empty object
|
||||
// https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object
|
||||
|
Reference in New Issue
Block a user