Array Patterns Interview Guide
The 8 essential patterns to master arrays — with templates, questions & company tags
Pattern Difficulty Frequency Stars
Easy –
Two Pointers Most Asked ★★★★★
Medium
Sliding Window Medium Most Asked ★★★★★
Easy –
Prefix Sum High ★★★★
Medium
Binary Search on Array Medium High ★★★★
Easy –
Hash Map / Frequency Count Most Asked ★★★★
Medium
Kadane's / Subarray DP Medium Medium ★★★
Merge Intervals Medium Medium ★★★
Sorting + Greedy Medium Medium ★★★
Pattern Deep-Dives
Two Pointers Most Asked
★★★★★ Easy – Medium
Sorted array, pairs summing to target, palindrome check, in-place operations
TOP QUESTIONS
Two Sum II (sorted) Google Amazon Meta
3Sum Amazon Microsoft Adobe
Container With Most Water Google Amazon
Remove Duplicates from Sorted Array Meta Apple
Valid Palindrome Meta Microsoft
Trapping Rain Water Amazon Google Netflix
CODE TEMPLATE
left, right = 0, len(arr) - 1
while left < right:
if condition(arr[left], arr[right]):
# process pair
left += 1; right -= 1
elif arr[left] too small: left += 1
else: right -= 1
Sliding Window Most Asked
★★★★★ Medium
Subarray/substring of fixed or variable size, max/min in window, distinct elements
TOP QUESTIONS
Longest Substring Without Repeating Chars Amazon Adobe Microsoft
Maximum Sum Subarray of Size K Google Flipkart
Longest Repeating Character Replacement Google Facebook
Minimum Window Substring Amazon Google Meta
Fruit Into Baskets Google Amazon
Permutation in String Microsoft Bloomberg
CODE TEMPLATE
left = 0
for right in range(len(arr)):
[Link](arr[right]) # expand
while window invalid:
[Link](arr[left])
left += 1
ans = max(ans, right - left + 1)
Prefix Sum High
★★★★ Easy – Medium
Range sum queries, subarray sum equals K, running totals
TOP QUESTIONS
Subarray Sum Equals K Amazon Meta Google
Product of Array Except Self Amazon Microsoft Apple
Range Sum Query Amazon Bloomberg
Find Pivot Index Amazon Adobe
Count Number of Nice Subarrays Google Grab
CODE TEMPLATE
prefix = [0] * (n + 1)
for i in range(n):
prefix[i+1] = prefix[i] + arr[i]
range_sum = prefix[r+1] - prefix[l]
# Subarray sum == k (hashmap)
seen = {0: 1}; running = 0
for x in arr:
running += x
count += [Link](running - k, 0)
seen[running] = [Link](running,0)+1
Binary Search on Array High
★★★★ Medium
Sorted or rotated array, search answer space, find boundary condition
TOP QUESTIONS
Search in Rotated Sorted Array Amazon Google Meta
Find Minimum in Rotated Array Microsoft Amazon
Koko Eating Bananas Amazon Google
Find First and Last Position Google Facebook Adobe
Capacity to Ship Packages in D Days Amazon Walmart
CODE TEMPLATE
lo, hi = 0, len(arr) - 1
while lo <= hi:
mid = (lo + hi) // 2
if arr[mid] == target: return mid
elif arr[mid] < target: lo = mid+1
else: hi = mid-1
# Answer-space binary search
while lo < hi:
mid=(lo+hi)//2
if feasible(mid): hi=mid
else: lo=mid+1
Hash Map / Frequency Count Most Asked
★★★★ Easy – Medium
Frequency count, two-sum variants, anagrams, grouping elements
TOP QUESTIONS
Two Sum (unsorted) Amazon Google Infosys
Group Anagrams Amazon Microsoft Meta
Top K Frequent Elements Amazon Google Uber
Longest Consecutive Sequence Amazon Google Apple
First Missing Positive Google Amazon
CODE TEMPLATE
from collections import Counter, defaultdict
freq = Counter(arr)
# Two sum
seen = {}
for i, x in enumerate(arr):
if target - x in seen:
return [seen[target-x], i]
seen[x] = i
# Grouping
groups = defaultdict(list)
for item in arr:
groups[key(item)].append(item)
Kadane's / Subarray DP Medium
★★★ Medium
Max/min subarray sum, buy-sell stock, maximum product subarray
TOP QUESTIONS
Maximum Subarray (Kadane's) Amazon Microsoft Adobe
Best Time to Buy and Sell Stock Amazon Google Cisco
Maximum Product Subarray Amazon Google Meta
Buy and Sell Stock with Cooldown Google Facebook
CODE TEMPLATE
# Kadane's Algorithm
max_sum = curr = arr[0]
for x in arr[1:]:
curr = max(x, curr + x)
max_sum = max(max_sum, curr)
# Buy/Sell Stock
min_price = float('inf'); profit = 0
for price in prices:
min_price = min(min_price, price)
profit = max(profit, price - min_price)
Merge Intervals Medium
★★★ Medium
Overlapping ranges, scheduling problems, calendar conflicts
TOP QUESTIONS
Merge Intervals Google Amazon Uber
Insert Interval LinkedIn Google
Meeting Rooms II Amazon Google Meta
Non-overlapping Intervals Google Microsoft
CODE TEMPLATE
[Link](key=lambda x: x[0])
merged = [intervals[0]]
for start, end in intervals[1:]:
if start <= merged[-1][1]:
merged[-1][1] = max(merged[-1][1], end)
else:
[Link]([start, end])
Sorting + Greedy Medium
★★★ Medium
Optimal arrangement, minimum operations, scheduling problems
TOP QUESTIONS
Task Scheduler Amazon Meta Airbnb
Jump Game Amazon Google Adobe
Min Arrows to Burst Balloons Google Bloomberg
Sort Colors (Dutch National Flag) Amazon Microsoft
CODE TEMPLATE
# Dutch National Flag (3-way partition)
lo, mid, hi = 0, 0, len(arr) - 1
while mid <= hi:
if arr[mid] == 0:
arr[lo], arr[mid] = arr[mid], arr[lo]
lo += 1; mid += 1
elif arr[mid] == 1: mid += 1
else:
arr[mid], arr[hi] = arr[hi], arr[mid]
hi -= 1
Company-wise Focus Areas
Amazon Two Pointers, Sliding Window, Prefix Sum, Kadane's — loves 'optimize the brute force'
Google Binary Search on answer space, Merge Intervals, hard Sliding Window + clean code
Meta/Facebook Two Pointers, Hash Maps, Subarray problems — strong focus on complexity analysis
Microsoft Balanced mix: Sorting + Greedy, Hash Map, basic Prefix Sum
Adobe / Flipkart / Two Pointers, Sliding Window, and medium Prefix Sum problems
Infosys
Study Priority Roadmap
Week 1–2 (Start
Two Pointers → Sliding Window → Hash Map → Prefix Sum
here)
Week 3 (Build on) Binary Search on array → Kadane's / Subarray DP
Week 4 (Polish) Merge Intervals → Sorting + Greedy
Array Patterns Interview Guide • 8 Patterns • 40+ Questions • Top Tech Companies