Skip to main content

All Questions

Tagged with
2 votes
1 answer
293 views

Ruby Connected Components in a Graph

I've written the following code to find the connected components of a graph in ruby, but it is quite slow since I don't use any sensible data structure for the disjoint sets, and hence find_set is ...
Darcy Harding's user avatar
1 vote
1 answer
111 views

Largest divisible subset optimization

So this is my solution to the following leetcode problem: https://leetcode.com/problems/largest-divisible-subset/description/ How could I optimize this code? I think the run time is \$\mathcal{O}(n^2)...
user3769323's user avatar
1 vote
1 answer
132 views

Multiset implementation in Ruby -Take 2

This is a follow up to question. I fixed the issues mentioned in the answer as far as my understanding. The union and intersection now return new object instances with new implementation. I also wrote ...
aarti's user avatar
  • 913
2 votes
1 answer
387 views

Multiset implementation in Ruby

I am trying to implement the Wikipedia definition of a MultiSet and need feedback on the implementation. ...
aarti's user avatar
  • 913
1 vote
1 answer
1k views

Custom set data structure in Ruby

I wrote a set data structure with some useful functions. I'm not sure if it is a good implementation and if there are other essential functions that a set should support. ...
aarti's user avatar
  • 913