DSA with Java Tutorial with Examples.
DSA with Java tutorial: data structures and algorithms in Java, from arrays, trees and graphs to dynamic programming and coding interview patterns.
Beginner
Start here — no prior experience needed
Java Collections and Their Real Costs
Which collection to reach for and what each operation costs — plus the Integer cache and autoboxing overhead that make Java's traps different.
Arrays and Two Pointers
Opposite ends, same direction and fast-slow in Java — with the invariant that proves each correct, and the array-copy costs that do not exist in Python.
Hashing and Counting in Java
HashMap, merge and computeIfAbsent, why an int array beats a map for characters, and the autoboxing tax that makes Java counting slower than a plain array.
Sliding Window in Java
Fixed and variable windows, the shrink condition that decides which you have, and why substring in a loop turns O(n) back into O(n squared).
Stacks and Monotonic Stacks in Java
Why ArrayDeque replaced the synchronized legacy Stack, the next-greater-element pattern, and the amortised argument that makes a nested-looking loop O(n).
Intermediate
For developers with core concepts down
Linked Lists and Trees in Java
Reference rewiring without losing the tail, the dummy-head idiom, recursive versus iterative traversal, and Java's StackOverflowError depth.
Graphs in Java: BFS, DFS, and Topological Sort
Adjacency lists with Map and List, why BFS finds shortest paths on unweighted graphs, and Kahn's algorithm for ordering dependencies.
Sorting, Binary Search, and Heaps in Java
Comparator without subtraction overflow, the binary search bug that lived in the JDK for years, and PriorityQueue for top-k without sorting all.
Advanced
Production-grade patterns for experienced engineers
Dynamic Programming in Java
Memoisation with int arrays rather than HashMap, bottom-up tables, the rolling-array space reduction, and long arithmetic where int silently overflows.
Backtracking in Java
The choose-explore-undo skeleton, why you must copy the path before adding it to results, and pruning that turns hours into milliseconds.