LeetCode's Top Interview 150 is its broadest free study plan, which it suggests for three or more months of preparation. In Java it covers nearly the whole java.util toolkit, and it also contains the problems where Java's own rules cause bugs: a comparison that fails only after index 127, sums that overflow at the int limit and a deque that comes out backwards. This page gives a Java-friendly order for its 23 groups, a table of those traps, collection idioms by group, the problems worth repeating and schedules for six to ten weeks. For the plan itself, see our LeetCode Top Interview 150 guide; for the same plan in Python, Top Interview 150 in Python.
The 23 groups in a Java-friendly order
The plan has 39 easy, 93 medium and 18 hard problems, none of them Premium. Counts were read from each list's own site data on November 12, 2026. Lists are edited from time to time, so numbers can drift. LeetCode lists the groups starting with 24 array and string problems; this order starts with index work and builds toward search and dynamic programming.
| Phase | Groups (problems) | Java you practise |
|---|---|---|
| 1. Arrays and indexes | Two pointers (5), sliding window (4), Kadane's algorithm (2), matrix (5), intervals (4) | int[], Arrays.sort(int[][], comparator), List<int[]> |
| 2. Strings and hashing | Array / string (24), hashmap (9) | StringBuilder, char[], String.repeat, HashMap.merge |
| 3. Linear structures | Stack (5), linked list (11) | ArrayDeque, sentinel nodes |
| 4. Numbers | Bit manipulation (6), math (6), binary search (7) | >>>, long, Integer.bitCount |
| 5. Trees and graphs | Binary tree general (14), BFS (4), BST (3), trie (3), divide and conquer (4), graph general (6), graph BFS (3) | recursion, ArrayDeque<TreeNode>, HashMap<Node, Node> |
| 6. Search and optimization | Heap (4), backtracking (7), 1-D DP (5), multidimensional DP (9) | PriorityQueue, boolean[] used, Arrays.binarySearch |
Where Java's rules cause bugs in this plan
Limits are from each problem's constraints on LeetCode, read on November 12, 2026.
| Problem | What goes wrong | Fix |
|---|---|---|
| Word Pattern | The one-line trick map.put(c, i) != map.put(w, i) compares Integer objects. It passes until index 128, where Java's Integer cache ends, and patterns can be 300 long | Compare with Objects.equals, or keep two int arrays or maps of ints |
| Average of Levels in Binary Tree | Node values span the full int range, so a level sum overflows | Sum in a long or double |
| Find K Pairs with Smallest Sums | Values go up to 10 to the power 9 in size, so two of them can pass the int limit | Compare sums as long |
| Pow(x, n) | n can be Integer.MIN_VALUE, and negating it gives the same negative number | Copy n into a long before negating |
| Sqrt(x) | mid * mid overflows for x near 2 to the power 31 | Use a long mid, or test mid <= x / mid |
| Palindrome Number | Reversing all digits of a large int overflows | Reverse only half the digits |
| Max Points on a Line | Double slopes as map keys need special cases for vertical lines, and Double treats 0.0 and -0.0 as different keys | Reduce dy and dx by their gcd with a fixed sign and key on the pair |
| Minimum Number of Arrows | Coordinates span the full int range, so a subtraction comparator overflows | Integer.compare |
Collection idioms by group
- Array / string: Insert Delete GetRandom O(1) pairs an
ArrayList<Integer>with aHashMap<Integer, Integer>of indexes; to remove, move the last element into the hole, update its index and remove the last slot, and pick with one sharedRandominstance. Text Justification pads with" ".repeat(n)(Java 11). Zigzag Conversion appends into aStringBuilder[]with one builder per row. - Hashmap: Group Anagrams sorts a
char[]and keys bynew String(chars)withcomputeIfAbsent. Isomorphic Strings keeps twoint[256]arrays of last-seen positions. Contains Duplicate II stores each value's last index. - Stack: Simplify Path splits on
"/", skips empty parts and".", and removes the last part on"..". UseaddLastandpollLast, thenString.join("/", deque): if you usepush, iteration runs from the most recent part and the path comes out reversed. Basic Calculator pushes the running result and sign at each opening bracket. - Linked list: LRU Cache in this group is meant to test the list, so build the doubly linked list with head and tail sentinel nodes and keep a
HashMap<Integer, Node>; mention LinkedHashMap as the library shortcut. Copy List with Random Pointer uses aHashMap<Node, Node>, or interleaves copies for O(1) extra space. - Trees: Binary Search Tree Iterator keeps an
ArrayDeque<TreeNode>of left spines. Count Complete Tree Nodes compares the leftmost and rightmost depths and returns(1 << h) - 1for perfect subtrees. Populating Next Right Pointers II links each level in O(1) space with a dummy node. - Graphs: Snakes and Ladders converts a square number to a row and column whose direction flips every row. Word Ladder edits a
char[]in place and checksnew String(chars)against aHashSet<String>. - Heap: IPO sorts projects by capital and moves affordable ones into
new PriorityQueue<>(Collections.reverseOrder())of profits. Find Median from Data Stream uses one heap of each kind. - Dynamic programming: Longest Increasing Subsequence can use
Arrays.binarySearch(tails, 0, len, x), which returns minus the insertion point minus one when x is absent, soif (i < 0) i = -(i + 1);gives the slot to overwrite. Triangle arrives asList<List<Integer>>; copy the last row into anint[]and work upward to avoid boxing.
Problems worth repeating
| Problem | Why it is worth a second pass in Java |
|---|---|
| Insert Delete GetRandom O(1) | Two structures kept in sync, a common design question |
| LRU Cache, hand-built | Sentinel nodes and pointer updates under time pressure |
| Basic Calculator | Stack of signs, character parsing with Character.isDigit |
| Copy List with Random Pointer | Identity maps, then the O(1) space version |
| Course Schedule II | Topological order with int[] indegree and an ArrayDeque |
| Word Search II | A trie plus backtracking, with pruning of found words |
| Best Time to Buy and Sell Stock IV | State machine DP that generalizes three easier problems |
Top Interview 150 shares 77 problems with NeetCode 150, by our count in November 2026, so the Java tools in NeetCode 150 in Java carry over.
Schedules for six to ten weeks
| Pace | Per week | How the phases fit |
|---|---|---|
| 6 weeks | About 25 problems, 20 hours | Phases 1 and 2 in weeks 1 and 2, phases 3 and 4 in week 3, phase 5 in weeks 4 and 5, phase 6 in week 6 |
| 8 weeks | About 19 problems | One phase a week, with phases 2 and 5 taking two weeks each |
| 10 weeks | About 15 problems | The eight-week order plus two weeks for redoing failed problems |
LeetCode runs Java on OpenJDK 25, as LeetCode's help page on language environments listed it on November 12, 2026, so records, var and switch expressions are available there; check the version in your interview editor. Short on time? LeetCode's shorter plan is covered in our LeetCode 75 guide.
Turning a list into interview skill
Any list only helps if the practice transfers to problems you have not seen. These habits make the difference:
- Time-box every attempt: about 25 minutes for a medium before you read a solution.
- Keep a log with one line per problem: the pattern, the key idea and the complexity.
- Redo failed problems after three days, a week and three weeks, without looking at your old code.
- Explain your approach out loud before and while you code, as you would to an interviewer.
- In the last two weeks, switch to unseen problems without topic labels.
The patterns most lists are built on are explained in array and string patterns and tree, graph and recursion patterns.
Where CoPilot Interview fits
Finishing a list is not the same as passing an interview: interviewers score how you explain your approach, your trade-offs and your complexity out loud. CoPilot Interview is an AI interview assistant; its free AI mock interview asks coding questions, listens to your spoken explanation and scores it out of ten with a model answer, which is the part a problem list cannot train. The free plan gives 15 minutes a day of live help in sessions of up to 15 minutes, with AI mock interviews included. Online assessments and live coding rounds usually forbid outside help, so practice now and follow your employer's rules on the day.
Disclosure: CoPilot Interview is our product, so weigh what we say about it accordingly.
Frequently asked questions
How many problems are in Top Interview 150?
150 in 23 groups: 39 easy, 93 medium and 18 hard, all free, according to LeetCode's study-plan data on November 12, 2026.
Is Java a good language for Top Interview 150?
Yes. Java's collections cover every group, and the plan is a good way to learn their edge cases, such as Integer caching, overflow and deque order.
Why does my Word Pattern solution fail only on long inputs?
Comparing the Integer values returned by map.put with != compares objects. Java caches Integer objects only from -128 to 127, so equal indexes from 128 up look different. Use Objects.equals.
How long does Top Interview 150 take in Java?
LeetCode suggests three months or more. With some practice, six to ten weeks at 15 to 25 problems a week is realistic.
Practice this interview before the real one
The AI mock interview builds questions from your resume and the job description, reads them aloud and scores each spoken answer out of 10. Included on the free plan.
Start a mock interview