We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c1e7aea commit 74c1829Copy full SHA for 74c1829
src/course-master-the-coding/data-structures/hash-tables/implementation-1.ts
@@ -0,0 +1,20 @@
1
+class HashTable {
2
+ private data: number[];
3
+ constructor(size: number) {
4
+ this.data = new Array(size);
5
+ }
6
+
7
+ _hash(key: string) {
8
+ let hash = 0;
9
+ for (let i = 0; i < key.length; i++) {
10
+ hash = (hash + key.charCodeAt(i) * i) % this.data.length;
11
12
+ return hash;
13
14
+}
15
16
+const myHashTable = new HashTable(50);
17
+// myHashTable.set('grapes', 10000);
18
+// myHashTable.get('grapes');
19
+// myHashTable.set('apples', 9);
20
+// myHashTable.get('apples');
0 commit comments