All Questions
Tagged with hash-map javascript
34 questions
5
votes
2
answers
2k
views
SHA-256 Hash with a short string length in javascript
I think I've found a way to somewhat "compress" the length of a SHA-256 hash. I am doing some addition, so I wanted to know whether an approach like this is secure or not.
...
4
votes
1
answer
3k
views
Merge two dictionaries
This function merges two dictionaries, using the value from the later dictionary to resolve conflicts.
I have 5 tests that the program passes successfully:
...
1
vote
2
answers
84
views
Shortest way possible to generate javascript string from a large array of values to A, B, C and n others
I have an array of values containing names, e.g.
let members = [{id: 1, name: 'Tyler'}, {id: 2, name: 'John'}, {id: 3, name: 'Dayo'}, ..., {id: 7, name: 'George']
...
1
vote
1
answer
2k
views
How to exclude elements from an array based on a Map while maintaining O(n)?
I am trying to exclude some elements from array items that include properties from array excludes.
I wrote this code which works ...
1
vote
1
answer
88
views
React - Component rendering weather data
Background:
Hello, I'm a student (since 2 months) and I've created a small MVP of a weather application. So now I'm refactoring my code because it looks hideous and it is hard to work with.
The ...
2
votes
1
answer
569
views
word frequency distribution
wordList is an array of non-empty strings ("words"). The following code I have written with the purpose of obtaining a Map, containing the unique words ...
0
votes
1
answer
78
views
Calculating ordered differences between elements in vector
Input
I start with a vector of integers or floats, e.g.:
[10, 100, 20, 5, 50]
Output
I want to return a list of differences or "deltas" between elements ...
4
votes
2
answers
865
views
JavaScript implementation of Symbol Table (Dictionary)
I'm currently going over Robert Sedgewick Algorithms book. Here I'm implementing a Symbol Table using a Linked List. The Sequential Search Symbol table is implemented in JavaScript. The book mentiones ...
3
votes
1
answer
533
views
SHA256 javascript implementation
I implemented a sha256 hash function for javascript just for a practice and I want to know if my code needs more improvement. Please tell me which to simplify if there's any. Thanks.
Here is my code:
...
0
votes
2
answers
96
views
Counting the amount of objects in an array that contain a certain key that doesn't have an empty value
Here is my source code:
...
3
votes
1
answer
78
views
Hash table with complex variable-length keys
I'm trying to implement the game Snake in Javascript and getting the computer to play it by itself, and want to check whenever the snake loops (repeats the same set of moves twice) so I can kill it.
...
1
vote
1
answer
94
views
Turn a list of words into a dictionary
I am looking for a way to turn a list of words that may have duplicates into a dictionary/map that counts the number of occurrences of words. After spending some time with the problem, this seems to ...
1
vote
1
answer
83
views
hashtable search in JavaScript
I've implemented the search/insert part of a hashtable in JavaScript.
This is in linear probing style. It resizes when the array is out of space.
...
1
vote
1
answer
3k
views
Frequency Queries hackerrank [closed]
This is the problem:
You are given queries. Each query is of the form two integers
described below:
- 1: Insert x in your data structure.
- 2: Delete one occurrence of y from your data ...
3
votes
1
answer
373
views
Buy and Sell a Stock for maximum profit (given a day and a price)
If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit.
Example one:
Input: [7,1,5,3,6,4]
...