Stage 1 · Code
Arrays & Strings
Arrays
Array fundamentals, slicing, and common patterns in Go.
Array Basics
Bubble Sort
Step 1 / 51 — Initial array
In Go, arrays have fixed size determined at compile time. They are value types — assignment copies the entire array. Most Go code uses slices (dynamic arrays) instead.
Slicing and Slices
Slices are the dynamic, flexible view into arrays. A slice has three components: pointer to underlying array, length (visible elements), and capacity (total allocated).
Common Array Patterns
- Two-pointer traversal: Left/right pointers for sorted arrays, palindromes.
- In-place modification: Use indices as implicit hash (e.g., negation trick for duplicates).
- Prefix sums: Precompute cumulative sums for O(1) range queries.
- Sliding window: Maintain window with left/right pointers for subarray problems.
- Binary search: On sorted arrays or answer space (monotonic property).
2D Arrays (Matrices)
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.