Command Palette

Search for a command to run...

Module 0

Java for DSA

Just enough Java to write any algorithm in this course: types, arrays, strings, objects, collections and sorting.

Beginner 5 lessons 2 problems ~80 min of lessons

This course uses Java for every solution. You don't need to be a Java expert: you need the small part of the language that algorithms use, and you need to know its traps (integer overflow, == on strings, boxed Integer comparisons).

If you already write Java at work, skim the lessons and try the two problems. If you're new, go slowly and run every snippet yourself with java Main.java (Java 11+ runs a single file without compiling first).

Part 1

Learn the ideas

Part 2

Solve the problems

In order of difficulty. Each one shows the pattern it teaches.

  1. Your first two-pointer algorithm: swap from both ends towards the middle, using O(1) extra space.

  2. Keeping a small running state (the largest and second largest so far) in one pass, and handling duplicates and tiny inputs carefully.