Code Explainers

Code explainers tagged #data-structures

go
package cache
 
import (
	"container/list"

Building a generic LRU cache in Go

lru-cache generics linked-list
Intermediate 8 steps
java
public class UnionFind {
    private final int[] parent;
    private final int[] rank;
    private int count;

How union-find with path compression works

disjoint-set path-compression union-by-rank
Intermediate 7 steps
javascript
class Stack {
  #items = [];
 
  push(value) {

Building a Stack with private fields

data-structures encapsulation iterators
Intermediate 7 steps
python
from collections import Counter
 
 
def word_frequencies(text):

Counting things with collections.Counter

counting multiset data-structures
Beginner 8 steps
ruby
class LinkedList
  include Enumerable
 
  Node = Struct.new(:value, :next_node)

Building an enumerable linked list in Ruby

linked-list enumerable data-structures
Intermediate 7 steps
typescript
class LRUCache<K, V> {
  private readonly capacity: number;
  private readonly map: Map<K, V>;
 

Building an LRU cache on a JS Map

caching data-structures generics
Intermediate 8 steps