Skip to main content

Questions tagged [set]

A set is a collection in which no element is repeated, which may be able to enumerate its elements according to an ordering criterion (an "ordered set") or retain no order (an "unordered set").

3 votes
1 answer
135 views

Generic Macro Generated Hashset in C

The Hashset uses open addressing, linear probing and Robin Hood hashing for handling collisions. It comes with insert and remove ...
LeoVen's user avatar
  • 337
4 votes
2 answers
1k views

Custom Hashset in Java

I have written this custom hashset and though it isn't completed yet, I would like to know if there is anything I am overlooking in terms of clean code conventions. My aim was also to apply generics ...
user200188's user avatar
3 votes
1 answer
110 views

unordered_set: a hash table -based set data structure in C89

In this post, I present a hash table -based set data structure written in C89: unordered_set.h ...
coderodde's user avatar
  • 28.9k
0 votes
1 answer
107 views

java.util.Set extension/implementation

Lately, I was working on some experimental java.util.Set extension, IdSet: ...
Wojciech Karwacki's user avatar
2 votes
1 answer
176 views

Powerset of collection in Clojure

Similar to this question, here's another implementation. Assume the input is already a set. ...
dimid's user avatar
  • 303
7 votes
1 answer
3k views

Sort int array by frequency then value

Problem Take an array of ints as input and run a special sorting algorithm on it. This algorithm must first sort by int frequency, less frequent first, then sort by value. For example ...
greg's user avatar
  • 1,017
4 votes
2 answers
4k views

Data Structures for Counting Duplicates and using std::vector::erase

Problem Dupe detection for a vector of ints. I simply want a count of the unique input characters that occurred at least twice. The goal is to count a dupe only once and ignore that input character if ...
greg's user avatar
  • 1,017
3 votes
1 answer
234 views

Test for an array being subset of another master array

I was trying to build a small utility function to check if an array is part of other array. It's testing if an array is a subset of another master array. ...
Harshal's user avatar
  • 141
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
1 vote
1 answer
3k views

All subsets of a String in java using recursion

I wrote this code for printing all sets of a String. It also prints the empty subset. Is this the right approach ...
Curious's user avatar
  • 13
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
1 vote
1 answer
314 views

Grow-only set (CRDT)

I made up a quick and dirty implementation of the G-Set in C#. I was hoping for some feedback on my approach. I'm not totally happy with having the payload public but I can't see that I'm gaining ...
Onorio Catenacci's user avatar
4 votes
2 answers
6k views

From a set of words, output all words that fit a string of random letters (like Scrabble)

I am in my first year of programming with Python 3 and am wondering if anyone had a better way to program this problem. When the user provides up to 7 random letters as a single string, the program ...
jtdans's user avatar
  • 43
2 votes
1 answer
1k views

set implementation based on an array

I was supposed to implement set without using any implemented structures. I would love to know what can I correct in my code, because I am not that much satisfied with its quality, so if you have any ...
nuxie's user avatar
  • 23
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

15 30 50 per page
1 2
3
4 5
10