Getting started

Understand the execution, not just the answer.

DSA Lab helps you inspect the state that interview questions hide: moving pointers, changing maps, search bounds, tree swaps, graph visits, and recursive calls — then tells you whether your solution actually passes.

01

Paste JavaScript, TypeScript, or Python

Use ordinary code in any of the three languages — switching rewrites the solution automatically. The visualizer observes arrays, pointers, maps, queues, graph nodes, trees, and recursion frames.

02

Add JSON input

Use the Input tab for the data your code expects — { "array": [4, 1, 3] } or { "graph": { "A": ["B"] } } — with one-click edge cases for common scenarios.

03

Control the trace

Hit Run, then play, pause, jump through states, or drag the timeline. Space plays, ←/→ step, Home/End jump — and the active code line follows along.

See it in action

A trace, one step at a time.

Five live demos, one per family — sorting, searching, trees, hashing, and recursion. Each one plays the real visualizer: bubble sort swaps values into place, binary search narrows its window, Invert Binary Tree mirrors a tree, Two Sum builds a hash map, and fibonacci grows and unwinds its recursive call stack.

Step 1 / 17
1const arr = [...input.array];
2
3for (let i = 0; i < arr.length - 1; i++) {
4 for (let j = 0; j < arr.length - i - 1; j++) {
5 if (arr[j] > arr[j + 1]) {
6 [arr[j], arr[j + 1]] = [arr[j + 1], arr[j]];
7 }
8 }
9}
10
11return arr;
5
0
3
1
8
2
1
3
2
4

Copy the input array

Step 1 / 7
1function binarySearch(arr, target) {
2 let lo = 0, hi = arr.length - 1;
3 while (lo <= hi) {
4 const mid = Math.floor((lo + hi) / 2);
5 if (arr[mid] === target) return mid;
6 if (arr[mid] < target) lo = mid + 1;
7 else hi = mid - 1;
8 }
9 return -1;
10}
11
12return binarySearch([1, 3, 5, 7, 9, 11, 13], 9);
1
0
3
1
5
2
7
3
9
4
11
5
13
6
lo 0hi 6

lo = 0, hi = 6 — the search space is the whole array

Step 1 / 6
1function invertTree(root) {
2 if (!root) return null;
3 [root.left, root.right] = [root.right, root.left];
4 invertTree(root.left);
5 invertTree(root.right);
6 return root;
7}
8
9return invertTree(tree);
4271369

Start at the root — invertTree(4)

Step 1 / 7
1function twoSum(nums, target) {
2 const seen = new Map();
3 for (let i = 0; i < nums.length; i++) {
4 const complement = target - nums[i];
5 if (seen.has(complement)) return [seen.get(complement), i];
6 seen.set(nums[i], i);
7 }
8 return [];
9}
10
11return twoSum([2, 7, 11, 15], 9);
20
71
112
153
seen map
— empty —

seen = {} — no numbers remembered yet

Step 1 / 43
1function fib(n) {
2 if (n <= 1) return n;
3 return fib(n - 1) + fib(n - 2);
4}
5
6return fib(5);
Recursive call stack
— empty —

Start the trace: call fib(5)

Built for interview prep

Beyond the sandbox.

The same engine that traces your pasted code powers a full practice curriculum — verified answers, quizzes, and comparisons so you know you're getting it right.

Top Interview 150 bank

Every question from LeetCode's Top Interview 150, grouped by topic with difficulty and tags. Each one opens in the visualizer with its solution, input, and answer ready to run.

Guided learning paths

Arrays → Two pointers → Sliding window → Recursion → Trees → Graphs → DP. Checkpoint quizzes along the way keep your practice structured, not scattered.

Instant pass/fail verdicts

Every traceable question ships with its known answer, so your run is graded automatically — even your own edited code — with a clear ✅ Pass or ❌ Fail in the Result tab.

Compare & measure

Toggle Compare to run brute force side-by-side with the optimal solution, and watch the ⚖ comparisons, 🔄 swaps, and ✍ writes counters diverge as you step.

New here? Take the tour.

A 30-second guided walkthrough of the visualizer — every panel, the operation counters, language switching, and the compare mode, with a live trace running underneath.

Best results

Start with the included presets, or paste a single algorithm function in JavaScript, TypeScript, or Python and keep the input serializable as JSON. The expected answer is pre-filled, so your run is graded the moment it finishes.