Skip to main content

All Questions

Tagged with
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: ...
Seth Lutske's user avatar
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 ...
Kudos B's user avatar
  • 21
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 ...
Rick's user avatar
  • 586
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 ...
heapOverflow's user avatar
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 ...
Luke's user avatar
  • 191
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 ...
nand's user avatar
  • 161