Practice
Interview-style problems chosen so each one demonstrates how a specific data structure is used in practice. Every problem includes progressive hints, a full Rust solution with tests, complexity analysis, and a real-world anchor.
-
Two Sum
easyin the wild Sensor calibration — pair up two readings whose sum matches a known reference.
-
Maximum Subarray (Kadane's)
mediumin the wild Best continuous window of SLAM confidence — the longest stretch of trusted tracking.
-
Trapping Rain Water
hardin the wild Terrain reservoirs — given an elevation profile, how much rainwater settles in the valleys?
-
Merge Two Sorted Linked Lists
easyin the wild Merging two sorted sensor streams (time-stamped) into one ordered timeline.
-
Reverse a Linked List
easyin the wild Reverse a transaction log to replay events in undo order; reverse a robot's trajectory chain for backtracking.
-
Detect a Cycle (Floyd's Tortoise and Hare)
mediumin the wild Detect an infinite loop in a state-machine transition graph; spot a follow-cycle in social graphs.
-
Min Stack
easyin the wild Robot recovery rollback — keep the cheapest known-safe state reachable in O(1) at any depth of a planning stack.
-
Evaluate Postfix Expression
mediumin the wild RPN calculators (HP-35), JVM bytecode VMs, the WebAssembly stack machine — all evaluate expressions exactly like this.
-
Next Greater Element
mediumin the wild Find the next higher temperature reading in a sensor stream; find the next price peak in a tick-by-tick feed.
-
Queue from Two Stacks
mediumin the wild Bridging a LIFO log-buffer to a FIFO consumer, or wrapping a stack-only API to expose queue semantics.
-
Bounded Ring Buffer (Robotics)
mediumin the wild Every ROS topic, every UART driver, every IMU sample stream: a fixed-capacity FIFO where producers can't be allowed to block consumers.
-
Sliding Window Maximum
hardin the wild Streaming sensor signal: report the maximum reading in the last k samples — a Kalman filter's gate threshold, a vibration-spike detector, a sliding-confidence summary.
-
Maximum Depth of Binary Tree
easyin the wild Computing a robot's kinematic chain depth (URDF leaf-to-root walk), or the max nesting depth of a JSON/DOM document.
-
Binary Tree Level-Order Traversal
mediumin the wild Wavefront expansion on an occupancy grid, organizational-chart visualization (one level per row), and 'show me the network neighbors at depth ≤ k'.
-
Diameter of Binary Tree
mediumin the wild Maximum hop count across a star/tree-shaped network; longest kinematic span across a robot's URDF (joint-to-joint farthest pair).
-
Lowest Common Ancestor in a BST
easyin the wild Find the most specific shared category of two products in a taxonomy tree, or the closest junction joining two waypoints in a routing tree.
-
Kth Smallest Element in a BST
mediumin the wild Order-statistic queries on a sorted index: 'show me the 100th highest-priority pending task', 'find the median sensor reading in this BST-backed sketch'.
-
Validate Binary Search Tree
mediumin the wild Sanity-check a freshly deserialized index, or an in-place tree that you've just rotated — does the BST invariant still hold?
-
Top K Frequent Elements
mediumin the wild Top-K trending topics, hot URL leaderboard, top-K product views — anywhere a streaming or batch system needs the heaviest hitters.
-
Median of a Data Stream
hardin the wild Latency percentiles in a streaming monitoring system, online sensor median (robust to outlier spikes), real-time score median for fairness.
-
Merge K Sorted Lists
hardin the wild External merge sort, log-file consolidation, distributed query results — anywhere k sorted streams must merge into one sorted output.
-
Group Anagrams
mediumin the wild Deduplicate sensor signatures up to permutation; cluster scrambled OCR'd words; group hash-collision keys.
-
Longest Substring Without Repeating Characters
mediumin the wild Detect the longest distinct-byte run in a packet stream; longest run of non-repeating tokens in an LLM prompt cache.
-
LRU Cache
mediumin the wild Every database buffer pool, every CPU cache layer, browser cache, Redis (with `allkeys-lru`), and OS page cache — the LRU eviction policy is everywhere.
-
Course Schedule (Topological Sort)
mediumin the wild Build-system task ordering (make, bazel), package dependency resolution, ROS launch-file ordering, microservice startup choreography.
-
Number of Islands
mediumin the wild Connected-component segmentation on an occupancy grid (which clumps of obstacles form one object?), region-counting in image masks, flood-fill in paint tools.
-
Shortest Path in a Maze (BFS)
mediumin the wild Wavefront path planner on a robot's occupancy grid; warehouse-AGV routing; tile-based-game pathfinding (Pacman, Dwarf Fortress).
-
Climbing Stairs
easyin the wild Counting paths through a state machine where each step has a fixed set of moves; the simplest 'cumulative count' DP that scales to any 1D recurrence.
-
Coin Change
mediumin the wild Cashier algorithms, transit-fare token minimization, network MTU packing, robot energy-budget step planning.
-
Longest Common Subsequence
mediumin the wild Every diff tool you've ever used (git diff, diff -u) computes LCS internally; bioinformatics sequence alignment (Needleman-Wunsch) is the weighted version.