Home / Blog

How to Learn DSA in Java in 2026: A Free, Step-by-Step Video Course

The order that actually works, the 10 lessons to start with, and a 352-problem practice sheet. All free.

By Amit Singh · Compiled Canvas

Most people who quit DSA don't quit because it's hard. They quit because they study it in a random order. They watch a dynamic programming video on Monday, a graphs video on Wednesday, and by Friday nothing connects.

I'm a Java developer with 11 years in the industry, and I'm building the course I wish I'd had: DSA in Java, from zero, in the right order. Every lesson is a short video with pictures and graphs instead of heavy theory, plus a free practice page with LeetCode problems, hints and Java solutions on compiledcanvas.com.

Here are the first 10 lessons, what each one teaches, and the one idea from each you should walk away with.

1. Start with the roadmap

Watch the video on YouTube
▶ Watch this lesson on YouTube

Before any code: what to learn, in what order, and how long each part takes. The short version is Big O first, then arrays and strings, then hashing, recursion, linked lists, stacks, trees, graphs and finally dynamic programming. Practise 3 to 5 problems per pattern instead of 500 random ones.

▶ Watch: DSA Roadmap 2026 · See the full 26-topic roadmap and practice sheet

2. Big O: why two correct programs aren't equal

Watch the video on YouTube
▶ Watch this lesson on YouTube

Two programs can give the same answer, and one takes a second while the other takes hours. Big O is how you tell them apart before you run anything. O(1) is one step. O(log n) halves the work each step, so a million items need about 20. O(n) is one loop. O(n²) is a loop inside a loop, and that's where solutions time out.

Big O drops constants. 3n + 5 is just O(n).

▶ Watch: Big O Notation Explained Simply · Practise: complexity problems

3. Calculating complexity of any code

Once you know the shapes, four rules cover almost every snippet: nested loops multiply, loops in a row add, a counter that doubles or halves is log n, and for recursion you multiply the number of calls by the work per call. The video walks through tricky cases like an outer loop that doubles with an inner loop that runs n times. That's O(n log n), not O(n²).

▶ Watch: How to Calculate Time Complexity of Any Code

4. The Java you actually need for DSA

Your logic can be perfect and Java can still fail your code. Two Integer objects holding 1000 are not == to each other. An int sum quietly overflows past 2.1 billion and turns negative. Building a string with + inside a loop is secretly slow. This lesson covers ArrayList, HashMap, HashSet and ArrayDeque, and the traps that fail real interviews.

▶ Watch: Complete Java for DSA · Practise: Java basics problems

5. The only math you need

Checking if a billion is prime by looping to n takes a billion steps. Stopping at the square root takes 31,623. That's the flavour of math in coding interviews: primes, the Sieve of Eratosthenes, GCD with Euclid's trick, and taking answers modulo 10⁹ + 7. One Java gotcha: −7 % 3 is −1, not 2.

▶ Watch: Basic Math for DSA · Practise: math problems

6. Bit manipulation

Every number appears twice except one. Find it. Most people reach for a HashMap. XOR every number together instead: pairs cancel out (x ^ x = 0) and the single number is left, in O(1) extra memory. The lesson builds AND, OR, XOR and shifts from scratch, plus the classic tricks like n & (n − 1) for powers of two.

▶ Watch: Bit Manipulation from Scratch · Practise: bit problems

7. Arrays, properly

Watch the video on YouTube
▶ Watch this lesson on YouTube

Why is reading arr[999999] one step, but inserting at the front a million? Because Java jumps straight to an address, but inserting shifts every value one seat to the right. This lesson uses lockers and cinema seats to make arrays obvious, and ends with reversing an array in place with two pointers.

▶ Watch: Array Data Structure in Java · Practise: array problems

8. Prefix sum: any range sum in one step

Build an array of running totals once, in O(n). After that, the sum of any range L to R is prefix[R + 1] − prefix[L], one subtraction. It's the trick behind a whole family of LeetCode problems. The most common mistake is forgetting that +1.

▶ Watch: Prefix Sum Explained · Practise: prefix sum problems

9. Two pointers: five patterns

Two indexes instead of two nested loops. Opposite ends for palindromes and pair sums in a sorted array; slow and fast pointers to remove duplicates in place. O(n) time, O(1) extra space. The video covers five patterns you'll see again and again.

▶ Watch: Two Pointers in Java: 5 Patterns · Practise: two pointer problems

10. Sliding window

Watch the video on YouTube
▶ Watch this lesson on YouTube

Don't recompute every window from scratch. Add the number that enters, drop the one that leaves. Fixed windows keep size k; variable windows grow on the right and shrink on the left while a rule is broken. Shrink with while, not if.

▶ Watch: Sliding Window in Java · Practise: sliding window problems

How to use this course

▶ Watch the full DSA in Java playlist on YouTube
🔔 Subscribe to Compiled Canvas so you don't miss the next lesson.