Find a lesson, question or project

Start typing to search published content and planned structures.

↑ ↓ moveEnter openEsc close

Arrays Learning Path

Learn array traversal, two pointers, in place updates, hashing, and prefix techniques through Java examples.

BasicsArraysPattern: array traversal

Arrays are usually the first data structure we study, but the important part is not memorizing individual solutions. The goal is to recognize a small set of patterns that appear again and again.

What to learn first

  1. Traverse an array without losing track of the current best answer.
  2. Update an array in place using one or two pointers.
  3. Use a HashMap or HashSet when repeated lookup is the expensive step.
  4. Use prefix information when many questions ask about a range.
  5. Sort only when the ordering helps more than it costs.

Start with Array Fundamentals, then solve these problems in order:

  1. Find the Largest Element
  2. Find the Second Largest Element
  3. Check Whether an Array Is Sorted
  4. Remove Duplicates from a Sorted Array
  5. Rotate an Array to the Left
  6. Move Zeroes to the End
  7. Union of Two Sorted Arrays
  8. Find the Missing Number
  9. Longest Subarray with Sum K

You can also browse the complete Arrays section by difficulty.

A useful habit

Before writing code, say what each variable means. If you use two pointers, define the role of both pointers. If you keep a running answer, explain what is guaranteed to be true after every iteration.

That sentence is often the real solution. The Java code is only its implementation.

Practice next

Next lessonArray Fundamentals in Java

Build a clear mental model for array indexing, traversal, updates, and common problem solving patterns.

Back to Arrays →