Skip to main content

All Questions

Tagged with
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 (...
coderodde's user avatar
  • 28.9k
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
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 ...
Arjen's user avatar
  • 63
4 votes
2 answers
185 views

Finding which items have at least one common value with other items

I have the following collection : ...
tigrou's user avatar
  • 421
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. ...
Prathu Baronia's user avatar
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
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 ...
Dima's user avatar
  • 161
6 votes
2 answers
4k views

Given 2 disjoint sets of intervals, find the intersections

...
user151542's user avatar
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 ...
Stack crashed's user avatar
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 ...
Subhomoy Sikdar'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
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 ...
Andrew G's user avatar
  • 195
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 ...
cpp beginner's user avatar
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 ...
user avatar
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: ...
coderodde's user avatar
  • 28.9k

15 30 50 per page