All Questions
Tagged with set javascript
6
questions
1
vote
1
answer
278
views
Managing duplicate class instances in a javascript Set
I have a class called Thing. For simplicity, let's say it initializes with a unique id, and that's all that's unique about it:
...
2
votes
3
answers
223
views
Sort an array of integers with a hashset
I was trying to make a sorting algorithm for an array of integers. Here's are the steps/theory:
It turns an array into a HashSet, iterates over every integer value ...
1
vote
1
answer
133
views
Possible letter combinations of a dial pad in linear time using a recursive approach
Time complexity: I walk the initial unzipped array of keys representing the number O(N) backwards. I then do an inner walk of the proceeding array of letters *O(L^2), mapping it to every value in the ...
2
votes
2
answers
162
views
Implementation of a shift operation for Set in JavaScript that emulates the one for arrays
I discovered that the JavaScript sets are ordered but don't offer a method to take the first element out of the set. For the arrays this operation exists and it's called shift.
A very basic ...
4
votes
3
answers
3k
views
Generate powerset in JS
I came across a mock interview question in which the candidate is asked to generate the powerset of a given set.
The input set is represented as a unique array of integers.
There was no solution ...
14
votes
1
answer
3k
views
Nested Sets in JavaScript
I created a procedural implementation of the nested set model in JavaScript.
The use case for this small library was that the front-end(presented as an MVC) needs to traverse hierarchical data from ...