Leetcode - Design HashSet (Python)

preview_player
Показать описание
August 2020 Leetcode Challenge
Leetcode - Design HashSet
Рекомендации по теме
Комментарии
Автор

Interesting thing to point out in your brute force solution is that you would have to create an array in since range goes up to but not including the number passed to it. Without accounting for this, when the input to the problem is you will get a "list index out of range error."

Joldzz
Автор

Why do I get error when I add self.array[key]=key

stephenraj
Автор

First, thanks for explaining it so well! Secondly, how do you think this would work in JavaScript? I ended up solving the problem (in JS), using this.set = new Set for initialize, and then this.set.add(key); this.set.delete(key), this.set.has(key) for the three other functions. Not quite sure if that not using a built in hash table library, so could use the help/clarification.

annad.
welcome to shbcf.ru