ARRAY & STRING – Pattern-wise Question Bank
(Phase-1 + Phase-2 Ready)
Phase-1: 15–20 questions per pattern (foundation). Phase-2: extend same pattern with 30–40
harder problems (CF + LC).
ARRAY PATTERNS
1. Two Pointers (Opposite Direction) – Array
Phase-1 Questions:
1 Two Sum II (sorted)
2 Container With Most Water
3 3Sum
4 3Sum Closest
5 4Sum
6 Trapping Rain Water
7 Squares of a Sorted Array
8 Boats to Save People
9 Minimize Maximum Pair Sum
10 Count Pairs With Sum < K
11 K-diff Pairs in an Array
12 Max Number of K-Sum Pairs
13 Bag of Tokens
14 Array With Elements Not Equal to Average of Neighbors
15 Closest Pair from Two Sorted Arrays
Phase-2 Extension: k-Sum generalization, heavy dedup, tighter constraints.
2. Two Pointers (Fast–Slow) – Array
Phase-1 Questions:
1 Remove Duplicates from Sorted Array
2 Remove Duplicates II
3 Remove Element
4 Move Zeroes
5 Duplicate Zeros
6 Partition Array According to Pivot
7 Sort Array by Parity
8 Sort Array by Parity II
9 Apply Operations to an Array
10 Valid Mountain Array
11 Check If N and Its Double Exist
12 Replace Elements with Greatest on Right
13 Decompress Run-Length Encoded List
14 Shuffle the Array
15 Move Even Integers to End
Phase-2 Extension: strict in-place constraints, stability + index tricks.
3. Sliding Window – Array
Phase-1 Questions:
1 Max Consecutive Ones III
2 Subarray Product Less Than K
3 Minimum Size Subarray Sum
4 Fruit Into Baskets
5 Binary Subarrays With Sum
6 Count Number of Nice Subarrays
7 Subarrays With K Different Integers
8 Grumpy Bookstore Owner
9 Sliding Window Maximum
10 Shortest Subarray With Sum ≥ K
11 Diet Plan Performance
12 Max Sum of Distinct Subarrays With Length K
13 Longest Turbulent Subarray
14 Maximum Points You Can Obtain from Cards
15 Subarray Product Greater Than K
Phase-2 Extension: atMost/exactly-K math, deque optimization.
4. Prefix Sum + Hash – Array
Phase-1 Questions:
1 Subarray Sum Equals K
2 Continuous Subarray Sum
3 Subarray Sums Divisible by K
4 Contiguous Array
5 Maximum Size Subarray Sum Equals K
6 Number of Zero-Filled Subarrays
7 Find Longest Subarray With Equal 0 and 1
8 Subarray With Given XOR
9 Make Sum Divisible by P
10 Count Subarrays With Fixed Bounds
11 Find Pivot Index
12 Ways to Split Array Into Three Subarrays
13 Range Sum Query
14 Maximum Erasure Value
15 Check Subarray Sum
Phase-2 Extension: mod tricks, prefix compression, constraint inversion.
STRING PATTERNS
1. Two Pointers – String
Phase-1 Questions:
1 Valid Palindrome
2 Reverse String
3 Reverse Words in a String
4 Backspace String Compare
5 Check If String Is Rotation
6 Palindrome Permutation
7 Remove Palindromic Subsequences
8 Sentence Similarity
9 Swap Adjacent in LR String
10 Compare Version Numbers
11 Valid Palindrome II
12 Check If One String Swap Makes Strings Equal
13 Merge Strings Alternately
14 Reverse Prefix of Word
15 Remove Trailing Zeros From String
Phase-2 Extension: unicode edge cases, relaxed constraints.
2. Sliding Window – String
Phase-1 Questions:
1 Longest Substring Without Repeating Characters
2 Longest Repeating Character Replacement
3 Minimum Window Substring
4 Permutation in String
5 Find All Anagrams in a String
6 Substring with Concatenation of All Words
7 Longest Substring with At Most Two Distinct Characters
8 Longest Substring with At Most K Distinct Characters
9 Maximize the Confusion of an Exam
10 Number of Substrings Containing All Three Characters
11 Longest Nice Substring
12 Count Substrings with Only One Distinct Letter
13 Substrings of Size Three with Distinct Characters
14 Replace the Substring for Balanced String
15 Longest Semi-Repetitive Substring
Phase-2 Extension: exact-K, multi-map windows, tight frequency bounds.
3. Frequency Map – String
Phase-1 Questions:
1 Valid Anagram
2 Ransom Note
3 Isomorphic Strings
4 Group Anagrams
5 First Unique Character in a String
6 Find the Difference
7 Check If All Characters Have Equal Frequency
8 Sort Characters by Frequency
9 Minimum Deletions to Make Character Frequencies Unique
10 Redistribute Characters to Make All Strings Equal
11 Check If a String Can Break Another String
12 Buddy Strings
13 Word Pattern
14 Find Common Characters
15 Maximum Number of Balloons
Phase-2 Extension: multi-string hashing, performance optimizations.
4. Prefix / Suffix – String
Phase-1 Questions:
1 Longest Common Prefix
2 Repeated Substring Pattern
3 Implement strStr
4 Check If String Is Prefix of Array
5 Count Prefixes of a Given String
6 Number of Strings That Appear as Substrings
7 Find the Index of the First Occurrence in a String
8 Count Common Words With One Occurrence
9 Split Strings by Separator
10 Remove Prefix
11 Check If Word Equals Summation of Two Words
12 Maximum Repeating Substring
13 Check If a Word Occurs As a Prefix of Any Word
14 Largest Substring Between Two Equal Characters
15 Check If All Prefixes Exist
Phase-2 Extension: KMP/Z-algo prep, rolling hash (Phase-2).