Given an array of integers, find two numbers that add up to a target.
This is the classic complement lookup pattern. Store value → index in a HashMap and check target - current.
Given a sorted array, remove duplicates in-place.
Because the array is sorted, duplicates are adjacent. Use slow/fast pointer technique.
Given a string, find the length of the longest substring without repeating characters.
This is a variable-size sliding window problem. Expand right, shrink left when duplicates appear.
Given a binary tree, return its level order traversal.
Level order traversal requires processing nodes level by level → BFS using a queue.
Find the maximum sum subarray.
This is Kadane’s Algorithm — dynamic programming where dp[i] represents max subarray ending at i.
Given a graph, determine if there is a path between two nodes.
This is basic graph traversal. Use DFS or BFS.
Merge overlapping intervals.
Sort intervals by start time, then greedily merge overlapping ones.
Find the kth largest element in an unsorted array.
This is a Top-K pattern. Use a min-heap of size k or Quickselect.
Check if a string is a valid palindrome.
Compare characters from left and right moving inward.
Count the number of connected components in an undirected graph.
This is a connectivity problem. Use DFS/BFS or Union-Find.
Premium Content
Unlock Pattern Recognition Quiz 1 and all premium lessons with a subscription.
From ₹199.99/year — See plans