All Questions
20
questions
1
vote
1
answer
82
views
Rewriting the java.util.concurrent.ConcurrentSkipListMap to a version without concurrency constructs
I have essentially rewrote the java.util.concurrent.ConcurrentSkipListMap into a version without concurrency constructs (...
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 ...
6
votes
1
answer
430
views
Remove elements compared with other elements in a Set based on a condition
Simplified the actual problem to focus on comparing/removing performance.
Given a set S with n elements , find the most optimal way to compare each element to all others until a condition is met that ...
4
votes
2
answers
185
views
Finding which items have at least one common value with other items
I have the following collection :
...
0
votes
2
answers
2k
views
Finding Repeat and missing numbers in an array
Problem Statement:
You are given a read-only array of n integers from 1 to n. Each
integer appears exactly once except A which appears twice and B which
is missing.
Return A and B.
...
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 ...
3
votes
3
answers
94
views
Finding duplicates between n Sets
I have n Objects,
Each Object has a Set of "nested" "Neighboring Objects".
I need to check if there are duplicates between the "Neighboring Objects" Sets (there are no duplicates inside a single Set ...
6
votes
2
answers
4k
views
4
votes
1
answer
5k
views
Compute power set of a given set in Python
Problem:
Given a set (let's say of integers), return the list of all of its subsets also known as the power set.
It looks to be working, but I would like feedback on the algorithm and Python ...
5
votes
2
answers
532
views
Forming sets from pairs of numbers
I do not want to use a new data structure but the existing APIs in Java. Here's a solution. I am thinking if this can be made simpler. Input say ...
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 ...
2
votes
1
answer
140
views
DisjointSet with O(1) find and O(1) amortised union
Does this code outperform the common implementation with path-compression and union-by-rank? I'm still okay with a review.
GitHub
...
2
votes
1
answer
532
views
Union Find implementation
I am trying to complete this challenge. The user should enter a sequence of instructions, = to link two numbers, and ? to query ...
5
votes
1
answer
2k
views
VERY simple C# Set implementation
This is not meant to solve any insane real world problems. I just want to make sure my Set logic is right and the code looks okay. It feels weird implementing it with a ...
2
votes
0
answers
1k
views
An AVL-tree based order statistic tree in Java
I have this java.util.Set implementation that is based on AVL-trees, which implies that the set is sorted. However, it provides two additional operations:
...