Introduction

This guide is for developers who want to solve algorithm problems in Java — whether you are new to the language or switching from C++/Python. It complements the LeetCode Templates collection: templates assume you already know which Java APIs to reach for; this guide teaches how Java works and when to use each tool.

Official references worth bookmarking:

Learning path

A practical order: language → collections → patterns → templates → timed practice.

Five phases Each phase maps to a section in this guide or a linked resource.
Java Learning Path for LeetCode Recommended progression from language basics to collections, patterns, and template practice. Java learning path for LeetCode Build foundations first, then collections, then reusable patterns and template practice. 1. Language types · arrays · strings control flow · methods 2. Collections HashMap · Set · Deque PriorityQueue · sort 3. Patterns two pointers · windows BFS · DFS · binary search 4. Templates copy-paste skeletons category families 5. Practice problem walkthroughs interview prep Parallel references • Oracle Java 21 API — docs.oracle.com/en/java/javase/21/docs/api/ • LeetCode Java environment — use Language dropdown on each problem • Collections Quick Reference — fast API lookup while coding • Modern Java (21→26) — records, pattern switch, List.of when JDK allows • LeetCode Templates — pattern index once basics feel comfortable
  1. Language — primitives, arrays, strings, control flow, classes. Start with Language Basics.
  2. CollectionsHashMap, HashSet, Deque, PriorityQueue. See Collections framework and the Quick Reference.
  3. Patterns — two pointers, sliding window, BFS/DFS, binary search. Covered in Common LeetCode templates.
  4. Templates — category-specific copy-paste code. Open the LeetCode Templates hub.
  5. Practice — work through problems by difficulty. Use the Questions List.

LeetCode Beginner's Guide

Topics: What LeetCode is, difficulty levels, constraint cheat sheet, phased roadmap (foundations → patterns → contests), Blind 75, practical tips

Language Basics

Topics: Program structure, types & variables, arrays, strings, control flow, methods & classes, collections framework, sorting & binary search, ListNode/TreeNode, sample usages, common templates, modern Java (21→26), tips & pitfalls

Collections Quick Reference

Topics: Compact API lookup for strings, arrays, ArrayList, HashMap, HashSet, TreeMap, PriorityQueue, Deque, Arrays/Collections utilities — ideal while coding under time pressure

LeetCode Templates

Topics: Category collections (graph, DP, heap, trees, etc.) — use after you are comfortable with Java syntax and core collections

LeetCode Questions List

Topics: All solved problems in this blog, organized by difficulty and category — apply what you learn from the guide

Quick start checklist

  • Can you declare int[], iterate with enhanced for, and use String.charAt?
  • Do you know when to use HashMap vs HashSet vs PriorityQueue?
  • Can you write a BFS with Queue and a DFS with Deque as stack?
  • Have you skimmed one template page (e.g. Graph) before attempting graph problems?

If any answer is “not yet,” work through Language Basics first.