Top 25 Java Dsa Problem Solving Patterns
Top 25 Java Dsa Problem Solving Patterns
in
else right--;
return false;
LeetCode Problems:
• https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/
• https://leetcode.com/problems/3sum/
• https://leetcode.com/problems/valid-palindrome/
• https://leetcode.com/problems/container-with-most-water/
• https://leetcode.com/problems/merge-sorted-array/
• https://leetcode.com/problems/remove-duplicates-from-sorted-array/
• https://leetcode.com/problems/valid-palindrome-ii/
• https://leetcode.com/problems/maximum-average-subarray-i/
• https://leetcode.com/problems/longest-substring-without-repeating-
characters/
www.iqmath.in
windowSum += arr[i];
maxSum = windowSum;
return maxSum;
LeetCode Problems:
• https://leetcode.com/problems/maximum-average-subarray-i/
• https://leetcode.com/problems/longest-substring-without-repeating-
characters/
• https://leetcode.com/problems/minimum-size-subarray-sum/
• https://leetcode.com/problems/permutation-in-string/
• https://leetcode.com/problems/longest-repeating-character-replacement/
• https://leetcode.com/problems/sliding-window-maximum/
• https://leetcode.com/problems/grumpy-bookstore-owner/
• https://leetcode.com/problems/max-consecutive-ones-iii/
Used mainly in linked list and cycle detection problems. Two pointers move at different
speeds—used for loops, palindromes, mid-point detection.
slow = slow.next;
fast = fast.next.next;
return false;
LeetCode Problems:
• https://leetcode.com/problems/linked-list-cycle/
• https://leetcode.com/problems/linked-list-cycle-ii/
• https://leetcode.com/problems/happy-number/
• https://leetcode.com/problems/middle-of-the-linked-list/
• https://leetcode.com/problems/palindrome-linked-list/
• https://leetcode.com/problems/intersection-of-two-linked-lists/
• https://leetcode.com/problems/find-the-duplicate-number/
Used when working with overlapping intervals. Helps in combining or scheduling tasks
efficiently.
merged.add(interval);
} else {
LeetCode Problems:
• https://leetcode.com/problems/merge-intervals/
• https://leetcode.com/problems/insert-interval/
• https://leetcode.com/problems/interval-list-intersections/
• https://leetcode.com/problems/meeting-rooms/
• https://leetcode.com/problems/meeting-rooms-ii/
• https://leetcode.com/problems/non-overlapping-intervals/
• https://leetcode.com/problems/employee-free-time/
• https://leetcode.com/problems/merge-sorted-array/
Used when working with arrays containing numbers in a fixed range (1 to n). Places each
number at its correct index.
int i = 0;
nums[i] = nums[correct];
nums[correct] = temp;
} else {
i++;
if (nums[j] != j) return j;
return nums.length;
LeetCode Problems:
• https://leetcode.com/problems/missing-number/
• https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/
• https://leetcode.com/problems/find-the-duplicate-number/
• https://leetcode.com/problems/first-missing-positive/
• https://leetcode.com/problems/set-mismatch/
• https://leetcode.com/problems/cyclically-rotating-a-grid/
• https://leetcode.com/problems/relative-ranks/
This pattern is used when reversing all or part of a linked list in-place. It’s especially
useful in palindrome check, reverse segments, or K-group reversal problems.
head.next = prev;
prev = head;
head = next;
return prev;
LeetCode Problems:
• https://leetcode.com/problems/reverse-linked-list/
• https://leetcode.com/problems/reverse-linked-list-ii/
• https://leetcode.com/problems/palindrome-linked-list/
• https://leetcode.com/problems/reverse-nodes-in-k-group/
• https://leetcode.com/problems/rotate-list/
• https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list/
• https://leetcode.com/problems/remove-nth-node-from-end-of-list/
• https://leetcode.com/problems/swap-nodes-in-pairs/
BFS explores the nearest neighbors first, level by level. It is widely used in tree and graph
traversals, shortest paths in unweighted graphs, and grid problems.
queue.offer(root);
while (!queue.isEmpty()) {
level.add(node.val);
result.add(level);
return result;
LeetCode Problems:
• https://leetcode.com/problems/binary-tree-level-order-traversal/
• https://leetcode.com/problems/minimum-depth-of-binary-tree/
• https://leetcode.com/problems/rotting-oranges/
• https://leetcode.com/problems/course-schedule/
• https://leetcode.com/problems/find-largest-value-in-each-tree-row/
• https://leetcode.com/problems/number-of-islands/
• https://leetcode.com/problems/open-the-lock/
• https://leetcode.com/problems/word-ladder/
DFS explores as deep as possible before backtracking. Useful in graph traversal, tree
recursion, backtracking, islands, and component counting.
visited[node] = true;
if (!visited[neighbor]) {
www.iqmath.in
LeetCode Problems:
• https://leetcode.com/problems/number-of-islands/
• https://leetcode.com/problems/clone-graph/
• https://leetcode.com/problems/path-sum/
• https://leetcode.com/problems/combination-sum/
• https://leetcode.com/problems/pacific-atlantic-water-flow/
• https://leetcode.com/problems/word-search/
• https://leetcode.com/problems/max-area-of-island/
• https://leetcode.com/problems/course-schedule-ii/
Classic pattern used when input is sorted or when the answer space is monotonic. Can
be applied over arrays, search ranges, or even in custom problem spaces.
return -1;
}
www.iqmath.in
LeetCode Problems:
• https://leetcode.com/problems/binary-search/
• https://leetcode.com/problems/search-in-rotated-sorted-array/
• https://leetcode.com/problems/find-first-and-last-position-of-element-in-
sorted-array/
• https://leetcode.com/problems/peak-index-in-a-mountain-array/
• https://leetcode.com/problems/search-a-2d-matrix/
• https://leetcode.com/problems/koko-eating-bananas/
• https://leetcode.com/problems/sqrtx/
• https://leetcode.com/problems/guess-number-higher-or-lower/
• https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/
if (temp.size() == n) {
result.add(new ArrayList<>(temp));
return;
if (temp.contains(i)) continue;
temp.add(i);
temp.remove(temp.size() - 1);
LeetCode Problems:
www.iqmath.in
• https://leetcode.com/problems/permutations/
• https://leetcode.com/problems/combinations/
• https://leetcode.com/problems/combination-sum/
• https://leetcode.com/problems/n-queens/
• https://leetcode.com/problems/letter-combinations-of-a-phone-number/
• https://leetcode.com/problems/subsets/
• https://leetcode.com/problems/restore-ip-addresses/
• https://leetcode.com/problems/palindrome-partitioning/
• https://leetcode.com/problems/generate-parentheses/
This pattern involves using bitwise operations (AND, OR, XOR, shifts) to solve problems
efficiently, often reducing space/time usage. Particularly useful for finding unique
numbers, subsets, parity, and flags.
int result = 0;
result ^= num;
return result;
LeetCode Problems:
• https://leetcode.com/problems/single-number/
• https://leetcode.com/problems/single-number-ii/
• https://leetcode.com/problems/subsets/
• https://leetcode.com/problems/number-of-1-bits/
• https://leetcode.com/problems/counting-bits/
• https://leetcode.com/problems/reverse-bits/
www.iqmath.in
• https://leetcode.com/problems/hamming-distance/
• https://leetcode.com/problems/missing-number/
Used when you're asked to find the top or bottom K elements. Max heaps or min heaps
are used to track the most relevant elements efficiently.
heap.addAll(freqMap.entrySet());
result[i] = heap.poll().getKey();
return result;
LeetCode Problems:
• https://leetcode.com/problems/top-k-frequent-elements/
• https://leetcode.com/problems/kth-largest-element-in-an-array/
• https://leetcode.com/problems/k-closest-points-to-origin/
• https://leetcode.com/problems/find-k-pairs-with-smallest-sums/
• https://leetcode.com/problems/reorganize-string/
www.iqmath.in
• https://leetcode.com/problems/task-scheduler/
• https://leetcode.com/problems/merge-k-sorted-lists/
int[] parent;
if (parent[x] != x)
parent[x] = find(parent[x]);
return parent[x];
parent[find(x)] = find(y);
LeetCode Problems:
• https://leetcode.com/problems/redundant-connection/
• https://leetcode.com/problems/number-of-provinces/
• https://leetcode.com/problems/graph-valid-tree/
• https://leetcode.com/problems/accounts-merge/
• https://leetcode.com/problems/friend-circles/
• https://leetcode.com/problems/satisfiability-of-equality-equations/
• https://leetcode.com/problems/most-stones-removed-with-same-row-or-
column/
Used when dealing with directed graphs that have dependencies. Topological sorting
gives an order of execution while honoring those dependencies.
graph.get(pair[1]).add(pair[0]);
indegree[pair[0]]++;
if (indegree[i] == 0) queue.add(i);
int index = 0;
while (!queue.isEmpty()) {
order[index++] = course;
if (--indegree[next] == 0) queue.add(next);
}
www.iqmath.in
LeetCode Problems:
• https://leetcode.com/problems/course-schedule/
• https://leetcode.com/problems/course-schedule-ii/
• https://leetcode.com/problems/alien-dictionary/
• https://leetcode.com/problems/sequence-reconstruction/
• https://leetcode.com/problems/sort-items-by-groups-respecting-
dependencies/
A trie is a tree-like data structure used to store strings in a way that allows fast lookup,
insert, and prefix matching.
class TrieNode {
class Trie {
}
www.iqmath.in
node.isEnd = true;
return false;
return node.isEnd;
LeetCode Problems:
• https://leetcode.com/problems/implement-trie-prefix-tree/
• https://leetcode.com/problems/add-and-search-word-data-structure-design/
• https://leetcode.com/problems/replace-words/
• https://leetcode.com/problems/longest-word-in-dictionary/
• https://leetcode.com/problems/design-search-autocomplete-system/
• https://leetcode.com/problems/word-search-ii/
• https://leetcode.com/problems/prefix-and-suffix-search/
if (c == '(') stack.push(')');
return stack.isEmpty();
LeetCode Problems:
• https://leetcode.com/problems/valid-parentheses/
• https://leetcode.com/problems/min-stack/
• https://leetcode.com/problems/largest-rectangle-in-histogram/
• https://leetcode.com/problems/daily-temperatures/
• https://leetcode.com/problems/next-greater-element-i/
• https://leetcode.com/problems/next-greater-element-ii/
• https://leetcode.com/problems/remove-k-digits/
• https://leetcode.com/problems/online-stock-span/
int n = nums.length;
stack.pop();
stack.push(i % n);
return res;
LeetCode Problems:
• https://leetcode.com/problems/next-greater-element-i/
• https://leetcode.com/problems/next-greater-element-ii/
• https://leetcode.com/problems/daily-temperatures/
• https://leetcode.com/problems/largest-rectangle-in-histogram/
• https://leetcode.com/problems/sum-of-subarray-minimums/
• https://leetcode.com/problems/132-pattern/
• https://leetcode.com/problems/sliding-window-maximum/
In greedy algorithms, you make the locally optimal choice at each step hoping it leads to
a globally optimal solution. Widely used in interval scheduling, coin change, and path
minimization.
int maxReach = 0;
return true;
}
www.iqmath.in
LeetCode Problems:
• https://leetcode.com/problems/jump-game/
• https://leetcode.com/problems/jump-game-ii/
• https://leetcode.com/problems/merge-intervals/
• https://leetcode.com/problems/non-overlapping-intervals/
• https://leetcode.com/problems/partition-labels/
• https://leetcode.com/problems/task-scheduler/
• https://leetcode.com/problems/candy/
• https://leetcode.com/problems/gas-station/
return maxSum;
LeetCode Problems:
• https://leetcode.com/problems/maximum-subarray/
• https://leetcode.com/problems/maximum-product-subarray/
• https://leetcode.com/problems/maximum-sum-circular-subarray/
• https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
• https://leetcode.com/problems/contiguous-array/
www.iqmath.in
• https://leetcode.com/problems/subarray-sum-equals-k/
• https://leetcode.com/problems/longest-well-performing-interval/
Prefix sums are useful when dealing with range sum queries. It transforms repeated
sum calculations into constant-time lookups using precomputed data.
return prefix;
LeetCode Problems:
• https://leetcode.com/problems/range-sum-query-immutable/
• https://leetcode.com/problems/find-pivot-index/
• https://leetcode.com/problems/subarray-sum-equals-k/
• https://leetcode.com/problems/maximum-size-subarray-sum-equals-k/
• https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-
operations/
• https://leetcode.com/problems/split-array-largest-sum/
• https://leetcode.com/problems/range-sum-of-bst/
1D Dynamic Programming is used when the solution of a problem depends on only one
previous state (or a linear sequence of decisions). Used for problems like Fibonacci,
house robber, and jump game.
if (n <= 2) return n;
twoStep = temp;
return oneStep;
LeetCode Problems:
• https://leetcode.com/problems/climbing-stairs/
• https://leetcode.com/problems/house-robber/
• https://leetcode.com/problems/fibonacci-number/
• https://leetcode.com/problems/jump-game/
• https://leetcode.com/problems/maximum-subarray/
• https://leetcode.com/problems/decode-ways/
• https://leetcode.com/problems/unique-paths/
• https://leetcode.com/problems/min-cost-climbing-stairs/
2D DP is used when solving problems on matrices or grids, often involving path finding,
edit distances, or counting combinations.
LeetCode Problems:
• https://leetcode.com/problems/unique-paths/
• https://leetcode.com/problems/minimum-path-sum/
• https://leetcode.com/problems/longest-common-subsequence/
• https://leetcode.com/problems/edit-distance/
• https://leetcode.com/problems/0-1-knapsack/
• https://leetcode.com/problems/interleaving-string/
• https://leetcode.com/problems/distinct-subsequences/
• https://leetcode.com/problems/maximum-length-of-repeated-subarray/
int n = matrix.length;
matrix[i][j] = matrix[j][i];
www.iqmath.in
matrix[j][i] = temp;
row[n - 1 - i] = temp;
LeetCode Problems:
• https://leetcode.com/problems/rotate-image/
• https://leetcode.com/problems/game-of-life/
• https://leetcode.com/problems/spiral-matrix/
• https://leetcode.com/problems/set-matrix-zeroes/
• https://leetcode.com/problems/search-a-2d-matrix/
• https://leetcode.com/problems/search-a-2d-matrix-ii/
• https://leetcode.com/problems/word-search/
subset.add(nums[j]);
result.add(subset);
return result;
LeetCode Problems:
• https://leetcode.com/problems/subsets/
• https://leetcode.com/problems/subsets-ii/
• https://leetcode.com/problems/letter-case-permutation/
• https://leetcode.com/problems/generate-parentheses/
• https://leetcode.com/problems/gray-code/
• https://leetcode.com/problems/count-the-number-of-consistent-strings/
• https://leetcode.com/problems/find-the-difference-of-two-arrays/
Recursion divides a problem into subproblems and solves them independently. Divide
and Conquer extends this by merging results, commonly used in merge sort, binary
search, etc.
int i = 0, j = 0, k = 0;
return merged;
LeetCode Problems:
• https://leetcode.com/problems/merge-sorted-array/
• https://leetcode.com/problems/sort-an-array/
• https://leetcode.com/problems/kth-largest-element-in-an-array/
• https://leetcode.com/problems/maximum-subarray/
• https://leetcode.com/problems/construct-binary-tree-from-preorder-and-
inorder-traversal/
• https://leetcode.com/problems/count-of-smaller-numbers-after-self/