Arrays —
The foundation of everything.
Arrays are where DSA begins. Once you can see every index, every pointer, every element shifting in real time — everything else clicks. Run your own Python array code and watch it execute step by step.
What are Arrays?
An array is an ordered collection of elements stored at contiguous memory locations. Every index maps directly to a memory address — which is why access is O(1). Once you understand arrays, every other data structure starts making sense because they're all built on top of this idea.
Why visualization changes everything
It's one thing to know that arr[2] = 5 assigns a value. It's another to watch the memory slot light up, the index pointer move, and the value update in real time. LearnBug removes all ambiguity — paste your array code, hit run, and see exactly what happens.
Every array operation, animated
From basic traversal to interview-critical patterns — see each one execute live.
Two Pointer Technique
Watch two indices close in from both ends simultaneously. The pattern behind pair sum, palindrome check, and container with most water.
Sliding Window
See a fixed-size or variable-size window slide across the array. Max subarray sum, longest substring without repeating — all visualized.
Binary Search
Watch the search space halve at every step. See low, mid, high pointers converge on the target in O(log n) time.
Kadane's Algorithm
Maximum subarray sum in O(n). Watch the running sum decision — extend the subarray or start fresh — play out at every element.
Prefix Sum
Precompute cumulative sums to answer range queries in O(1). Watch the prefix array build and see instant subarray sum lookups.
Merge Sorted Arrays
Classic two-pointer merge. Watch both pointers advance and smaller elements flow into the result array in sorted order.
Rotate Array
Three-reversal trick vs extra space. Watch elements shift positions and understand the O(n) in-place trick step by step.
Find Duplicate
Brute force, hash set, and Floyd's cycle approach. Watch three different methods find the duplicate — and see why complexity differs.
2D Array Traversal
Row by row, column by column, diagonal, spiral — watch the pointer navigate every path through the grid in real time.
Array Index Out of Bounds
The most common beginner mistake. Watch the pointer walk past the last valid index and see exactly why the error fires.
What you'll understand after these lessons
Run your own array code on LearnBug
Paste your solution — bugs and all. See exactly where your index logic goes wrong.