mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Notes:
|
||||
* - works by using divide and conquer
|
||||
* - the function gets the array A with n Real numbersand returns the local max point index (if more than one exists return the first one)
|
||||
* - the function gets the array A with n Real numbers and returns the local max point index (if more than one exists return the first one)
|
||||
*
|
||||
* @complexity: O(log(n)) (on average )
|
||||
* @complexity: O(log(n)) (worst case)
|
||||
|
@ -83,8 +83,8 @@ Trie.prototype.remove = function (word, count) {
|
||||
if (child.count >= count) child.count -= count
|
||||
else child.count = 0
|
||||
|
||||
// If some occurrences are left we dont delete it or else
|
||||
// if the object forms some other objects prefix we dont delete it
|
||||
// If some occurrences are left we don't delete it or else
|
||||
// if the object forms some other objects prefix we don't delete it
|
||||
// For checking an empty object
|
||||
// https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object
|
||||
if (child.count <= 0 && (Object.keys(child.children).length && child.children.constructor === Object)) {
|
||||
@ -110,7 +110,7 @@ Trie.prototype.contains = function (word) {
|
||||
return true
|
||||
}
|
||||
|
||||
Trie.prototype.findOccurences = function (word) {
|
||||
Trie.prototype.findOccurrences = function (word) {
|
||||
// find the node with given prefix
|
||||
const node = this.findPrefix(word)
|
||||
// No such word exists
|
||||
|
Reference in New Issue
Block a user