DSA Playback — Algorithm Visualizer & Big-O Explainer
Watch your data-structures-and-algorithms code run, one step at a time — and see why it
has the complexity it has. For C#, Python, Java, C++, JavaScript, TypeScript and Rust, written the way
LeetCode writes it.
- Runs on your machine. Nothing to set up for C#: the engine is inside the
extension. For Python, the Python you already have is used (3.9 or later).
- No sign-in. No account, and nothing is collected about you.
- Your code never leaves your computer — unless you turn on the optional AI
explanation, which sends a step to your own Copilot when you ask.
- Explains why a solution is O(n²), line by line — "When the input doubles, this
takes about four times as long, because line 10 runs once for every pair of items."

Watch it run
Open a C#, Python, Java, C++, JavaScript, TypeScript or Rust solution. Above every method you can run
there are two buttons:
▶ Visualize — plays your code step by step, with your data drawn and moving:
- arrays with
i, j, left, right, mid… as pointers that slide, and swapped
values that trade places
- linked lists whose arrows bend as you rewire them —
prev, curr and next label
the nodes they point at
- trees, with the nodes your recursion is working on marked
- graphs, with visited nodes and the BFS queue
- hash maps and sets whose entries animate in and out; stacks, queues and heaps
- the call stack, and a recursion tree showing what every call returned
- memory: what each line allocates, and the total as the run goes
The current line lights up in the editor. ← and → step, Space plays, and the speed
goes from 0.25× to 4×.
Complexity — runs your code on bigger and bigger inputs and explains how its time
and memory grow, line by line.


Paste LeetCode's example as a comment above your solution:
// Example 1:
// Input: nums = [2,7,11,15], target = 9
// Output: [0,1]
In Python, the same comment with #:
# Input: nums = [2,7,11,15], target = 9
# Output: [0,1]
▶ Visualize runs exactly that input and checks your answer against the expected
output — ✓ Matches or ✗ Expected [0,1], got [1,0]. A call with values written out
works too, in Main or under if __name__ == "__main__"::
int[] nums = { 2, 7, 11, 15 };
new Solution().TwoSum(nums, 9);
if __name__ == "__main__":
print(Solution().twoSum([2, 7, 11, 15], 9))
Several examples? Pick one from the list, or press Run all examples to check every
one at once — each gets a ✓ or ✗, and clicking it plays that example. No example?
Values are generated for you at a size you choose. Want something else? Type it in LeetCode's format —
[2,7,11,15], "abcabcbb", [[1,0],[0,1]], or a tree as [3,9,20,null,null,15,7] —
and press Enter.
Why it's O(n²), not just that it is

Complexity shows:
- the answer in plain words first — "When the input doubles, this takes about four
times as long" — then the notation
- how often each line ran and the memory it allocated, written beside the line
- the line that sets the method's class, and how many times it runs (≈ 0.5·n² times)
- work hidden inside library calls —
List.Contains in C#, or x in some_list in
Python, inside a loop is O(n²) even though every line looks O(1)
- memory: total allocated, the largest single allocation, and how deep recursion goes
- a reading of the code alongside the measurement, with any disagreement explained
When something goes wrong
- Your code throws: "Your code threw IndexOutOfRangeException at line 12" — the run
plays up to that line, and Show line takes you there.
- An endless loop or a missing base case is stopped and explained, never left hanging.
- A typed value that cannot be read is marked under its own box, with the position.
- A method taking a type that cannot be generated — a
double, a List<string> —
runs on the values in its example. Without an example, it says to add one.
- The visualizer itself fails: Report a Problem opens a GitHub issue filled in with
the versions and the recent log, for you to read before sending. Your code is never
included.
Explain this step (optional, off by default)
Turn on DSA Playback: Explain With AI (dsaPlayback.explainWithAI) to get an
✨ Explain this step button in the run view, answered by your own GitHub Copilot in
plain English. Turning it on sends your code to Copilot — the code you are stepping
through, the current line and its variables — and only when you press the button. VS Code
asks your permission the first time. Needs VS Code 1.90 or later and a Copilot sign-in.
Everything else in DSA Playback stays on your machine.
Questions
Ask in Discussions. If
DSA Playback helps you, a rating helps other students find it.
Design problems
LRU Cache, Min Stack, Implement Trie: a class, and LeetCode's two-line example of the
calls to make on it.
// Input
// ["LRUCache", "put", "put", "get"]
// [[2], [1, 1], [2, 2], [1]]
// Output
// [null, null, null, 1]
public class LRUCache { … }
▶ Visualize appears above the class. It creates the object, makes every call in
order, and checks the list of results against Output. The run view says which call is
running — Call 4 of 10: get — and, inside its methods, the object's own fields beside the
other variables. Type other calls in the same two-list format to try your own.
Complexity answers the way LeetCode asks — per call. Each size n makes n calls,
repeating your example's calls with new values (a cache of capacity n; keys from 0 to
n − 1), and each method gets its own verdict: put: O(1) per call, or get: O(n) per call,
because order.remove(key) on line 23 scans the list.
In every language DSA Playback supports: C#, Python, Java, C++ and TypeScript — a class,
as LeetCode writes it; JavaScript — a class, or LeetCode's prototype style,
LRUCache.prototype.get = function; and Rust — a struct with fn new and methods taking
&self or &mut self.
Files from LeetCode
Solutions copied from LeetCode, or made by the LeetCode extension, run as they are —
no using lines to add, and TreeNode and ListNode are supplied when the file leaves
them commented out. If the problem's description is in the file, its examples are used.
Get started
Open the Command Palette and run Welcome: Open Walkthrough…, then Get started with
DSA Playback. Three samples — two pointers, a tree BFS, and memoised dynamic
programming — open ready to run.
C++
C++ files work the same way, built with the compiler you already have: clang++ or g++
with C++17 (set dsaPlayback.cppCompiler to choose one). Write it as LeetCode does —
class Solution { public: … } with no #include or using namespace std, and
TreeNode and ListNode left commented out; they are supplied. Memory is exact: every
byte your code allocates with new, each container's storage included. The first run
compiles your code, which takes a second or two; later runs reuse the build until you
change the file. No compiler? DSA Playback says how to install one for your system.
Not yet for C++: examples written as calls in main, and Microsoft's compiler (MSVC).
Java
Java files work the same way, built with your own JDK (17 or later; set
dsaPlayback.javaHome to choose one). Write it as LeetCode does — class Solution { … }
with no imports, and TreeNode and ListNode left commented out; LeetCode's imports and
those classes are supplied. Design problems — LRU Cache, Min Stack — work as in C# and
Python: one ▶ Visualize on the class, and LeetCode's example of the calls.
Memory is exact: every byte your code allocates, from the JVM's own count. When measuring,
your code runs once to warm up before the run that is counted, so the JVM loading its own
classes is never mistaken for your allocations — unless your code keeps state in static
fields, which a second run would change.
Not yet for Java: examples written as calls in main, code split across several files,
and libraries outside the JDK.
JavaScript and TypeScript
JavaScript and TypeScript files work the same way, run with your own Node.js (18 or later;
set dsaPlayback.node to choose one). TypeScript needs nothing more: its compiler ships
with the extension. Write it as LeetCode does — var twoSum = function(nums, target) with
LeetCode's JSDoc (@param {number[]} nums), or a TypeScript function with its types — and
leave TreeNode and ListNode commented out; they are supplied. So are LeetCode's
MinPriorityQueue, MaxPriorityQueue, PriorityQueue, Queue and Deque, drawn as a
heap and a queue.
Complexity charges the work hidden in includes and indexOf on an array, shift and
unshift, splice, slice, sorting, spreading and string += — never Set.has or
Map.get. Memory is an estimate, made where each array, object, map, set and string is
created; Node cannot report what one line allocated, so the figures are the same on every run
but approximate.
Not yet for JavaScript and TypeScript: require or import of packages beyond LeetCode's
own, and Node.js before 18.
Rust
Rust files work the same way, built with your own rustc (installed by rustup; set
dsaPlayback.rustc to choose one). Write it as LeetCode does — impl Solution { pub fn … }
with no struct Solution;, and TreeNode and ListNode left commented out; they are
supplied. Memory is exact: every byte your code allocates on the heap.
The run view also shows Rust's ownership rules as your code runs. A variable the
compiler would not let be read at a step is listed with the reason: moved,
borrowed, not set yet, or no longer used — the last for a reference after
its last use, when its borrow has ended.
An integer overflow panics when you press Visualize, as in a debug build, and names its
line. When measuring complexity at large sizes it wraps instead, as in a release build.
Not yet for Rust: examples written as calls in main, crates outside the standard
library, and stepping inside a closure whose body is a single expression.
Python
Python files work the same way, with the Python you already have (3.9 or later): the
interpreter selected in the Python extension, or python3 on your path. Use LeetCode's
template — type hints like nums: List[int] tell the visualizer what to generate, and
TreeNode, ListNode, List, Optional, deque and heapq are there without an
import, as they are on LeetCode. Memory figures come from Python's tracemalloc and are
approximate.