Skip to main content

Questions tagged [data-structures]

For challenges involving ways to organize data (hash maps, arrays, binary trees ...)

Filter by
Sorted by
Tagged with
1 vote
2 answers
312 views

Input You are given 2 positive integers, n, q, followed by q queries. the queries can be of two forms: 0 a b: add the line a*x + b. a and b are integers between -...
3RR0R404's user avatar
  • 115
24 votes
16 answers
3k views

You're given an array of positive integers. Your job is to sort them using an initially empty deque (double-ended queue) by the following procedure: Take a number from the front of the array, and ...
Bubbler's user avatar
  • 79.3k
8 votes
33 answers
1k views

Challenge: Given the input array l with a list of strings, only keep the elements in the sequence that have a letter that's repeated at least 3 times. Like ...
U13-Forward's user avatar
  • 2,031
13 votes
10 answers
736 views

Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Fen is a magician Elf. He can cast spells on an array of numbers to produce another number or array of numbers. One ...
Bubbler's user avatar
  • 79.3k
12 votes
4 answers
377 views

A binary max heap is a rooted tree with integer labeled nodes such that: No node has more than 2 children. The label of every node is greater than all of its children. We say a sequence of integers ...
cjquines's user avatar
  • 1,391
43 votes
52 answers
3k views

For this challenge, a linked list looks like this: [1, 2, 4, 0, 6, 1, 3, 1] You'll notice there's no data; each item in the list is just a reference to the index ...
rydwolf's user avatar
  • 19.3k
25 votes
3 answers
806 views

Given a possibly nested, non-empty array of single-digit positive integers (not guaranteed unique), output the ASCII-art representation as a tree, using the box-drawing characters ...
AdmBorkBork's user avatar
  • 43.7k
17 votes
31 answers
2k views

I use "suffix" loosely here to mean "any sub-string that follows the prefix". "Prefix" here means the START of a word, where a word's start is defined as either after a space or from the first ...
DrQuarius's user avatar
  • 680
7 votes
4 answers
370 views

Background Here you have another work-inspired challenge, but from my wife's work in this case. Imagine you have a service that returns the list of nodes in a tree structure (much like the files and ...
Charlie's user avatar
  • 13k
5 votes
1 answer
1k views

From the sandbox! I2c or TWI, is a 2 way stream that uses 2 signal lines: SDA and SCK. This is used in sensors to communicate ...
tuskiomi's user avatar
  • 3,871
8 votes
6 answers
501 views

Here's the phonetic alphabet: ...
rybo111's user avatar
  • 4,565
15 votes
6 answers
1k views

Rules No cell range references (A2:B3). Maximum 9 rows and 9 columns. No circular references or formula errors. Empty cells evaluate to ...
Adám's user avatar
  • 31.8k
71 votes
66 answers
7k views

In: Enough memory and a positive integer N Out: N-dimensional N^N array filled with N, where N^N means N terms of N-by-N-by-N-by... Examples: 1: [1] ...
Adám's user avatar
  • 31.8k
9 votes
2 answers
423 views

Introduction A radix tree, also known as compressed trie or compressed prefix tree, is a tree-like data structure for storing a set of strings. The edges of the tree are labeled by nonempty strings, ...
Zgarb's user avatar
  • 43.2k
20 votes
4 answers
460 views

A stem and leaf plot displays a bunch of numerical values in groups, which are determined by all but the last digit. For example, suppose we have this set of data: ...
Ben N's user avatar
  • 1,723
21 votes
11 answers
862 views

A bag, also called a multiset, is an unordered collection. You can call it a set that allows duplicates, or a list (or an array) that is not ordered/indexed. In this challenge, you are asked to ...
busukxuan's user avatar
  • 2,838
7 votes
3 answers
604 views

At some point, I bumped into an SO question asking how to implement Perl's trivial hash-of-hashes data structure in Java. For those who don't know Perl, the hash value can be a scalar or another ...
DVK's user avatar
  • 271
18 votes
7 answers
585 views

Write a program that takes in a string where every line consists of the character 0 indented by some number of spaces. The top line is not indented and every other ...
Calvin's Hobbies's user avatar
19 votes
2 answers
458 views

You're given a tree, which in computer science tradition, has the root at the top and leaves at the bottom. The leaf nodes are labelled with numbers. Your goal is to take the special leaf marked ...
xnor's user avatar
  • 150k
6 votes
2 answers
1k views

Write a program that outputs a graph of the collatz sequence any way you want (ASCII Image Video etc). You have to implement it that way that you can adjust the size of the graph by either the maximum ...
flawr's user avatar
  • 44.1k
6 votes
11 answers
5k views

In the fewest bytes, generate the dictionary of keypresses for any letter (as described in https://code.google.com/codejam/contest/351101/dashboard#s=p2) In Python, the dictionary literal itself: <...
dspyz's user avatar
  • 943
5 votes
4 answers
1k views

Challenge Write the shortest program that implements the minimum requirements for a linked list, stack and queue. Minimum requirements Functions that allow the user to add and remove elements from ...
user avatar
21 votes
9 answers
2k views

This is a nice exercise for becoming more fluent in that programming language you've been meaning to learn, but have only tinkered with lightly. This involves working with objects, using or ...
Joey Adams's user avatar
  • 10.6k