Top 10 most array problems for FAANG interview
Here are the Top 10 most common and high-impact array problems that frequently appear in FAANG interviews (Google, Amazon, Meta, Apple, Netflix, Microsoft, etc.), with difficulty levels, patterns, and reasoning focus.
🧠 Top 10 Array Problems for FAANG Interviews
| # | Problem | Pattern / Concept | Key Skills Tested | Typical Difficulty |
|---|---|---|---|---|
| 1️⃣ | Two Sum | Hashing | Hash map lookup to find complements | Easy |
| 2️⃣ | Best Time to Buy and Sell Stock | Kadane’s variation / Sliding window | Greedy profit calculation | Easy–Medium |
| 3️⃣ | Product of Array Except Self | Prefix/Suffix product | Avoiding division, O(n) solution | Medium |
| 4️⃣ | Maximum Subarray Sum (Kadane’s Algorithm) | Dynamic programming | Running sum tracking | Medium |
| 5️⃣ | Merge Intervals | Sorting + Merging | Overlap handling logic | Medium |
| 6️⃣ | Dutch National Flag / Sort Colors | Two pointers | In-place sorting (0,1,2) | Medium |
| 7️⃣ | Container With Most Water | Two pointers | Area optimization | Medium |
| 8️⃣ | 3Sum / 4Sum | Sorting + Two pointers | Combination logic & duplicates handling | Medium–Hard |
| 9️⃣ | Find Duplicate Number | Floyd’s Cycle Detection / Hashing | Detecting cycle or repeated element | Medium |
| 🔟 | Trapping Rain Water | Two pointers / Stack | Area computation using boundary heights | Hard |
⚙️ Quick Pattern Summary
| Pattern | Example Problems | Focus |
|---|---|---|
| Two Pointers | Two Sum (sorted), 3Sum, Container with Most Water, Sort Colors | Moving inward, optimizing space |
| Prefix/Suffix / Kadane | Max Subarray, Product Except Self, Buy-Sell Stock | Subarray accumulation, O(1) space |
| Sorting-based | Merge Intervals, 3Sum, Meeting Rooms | Handling order & overlap |
| Hash Map | Two Sum, Subarray Sum = K, Find Duplicate | Constant time lookups |
| Stack | Trapping Rain Water, Next Greater Element | Tracking elements with conditions |
🏁 Bonus Problems (Honorable Mentions)
| Problem | Why Important |
|---|---|
| Rotate Array | In-place reversal technique |
| Find Missing Number | XOR or arithmetic trick |
| Subarray Sum Equals K | Prefix sum + hash map |
| Maximum Product Subarray | DP with positive/negative tracking |
| Longest Consecutive Sequence | Hash set O(n) logic |
🔍 Tips for Array Questions
- Always identify the pattern first (sliding window, two pointers, prefix sum, etc.).
- Focus on time complexity → most answers must be O(n) or O(n log n).
- Write edge cases mentally — empty array, duplicates, negative numbers.
- Be ready to code in any of C++ / Java / Python.
🧠 Top 10 Array Problems — Quick Strategy & Code
| # | Problem | One-Liner Strategy | Python Code Snippet |
|---|---|---|---|
| 1️⃣ | Two Sum | Use a hash map to find the complement target - num in O(n). | python def twoSum(nums, target): seen = {} for i, n in enumerate(nums): if target - n in seen: return [seen[target - n], i] seen[n] = i |
| 2️⃣ | Best Time to Buy & Sell Stock | Track min price & max profit on each iteration. | python def maxProfit(prices): minp, profit = float('inf'), 0 for p in prices: minp = min(minp, p); profit = max(profit, p - minp) return profit |
| 3️⃣ | Product of Array Except Self | Compute prefix * suffix products in O(n) w/o division. | python def productExceptSelf(nums): res = [1]*len(nums) left = 1 for i in range(len(nums)): res[i] = left; left *= nums[i] right = 1 for i in range(len(nums)-1,-1,-1): res[i] *= right; right *= nums[i] return res |
| 4️⃣ | Maximum Subarray (Kadane’s) | Track running max; reset when negative. | python def maxSubArray(nums): best = cur = nums[0] for n in nums[1:]: cur = max(n, cur + n); best = max(best, cur) return best |
| 5️⃣ | Merge Intervals | Sort by start; merge overlapping intervals. | python def merge(intervals): intervals.sort() res = [intervals[0]] for s, e in intervals[1:]: if s <= res[-1][1]: res[-1][1] = max(res[-1][1], e) else: res.append([s, e]) return res |
| 6️⃣ | Sort Colors (Dutch Flag) | Use 3 pointers (low, mid, high). | python def sortColors(nums): l, m, r = 0, 0, len(nums)-1 while m <= r: if nums[m]==0: nums[l], nums[m]=nums[m],nums[l]; l+=1; m+=1 elif nums[m]==2: nums[m],nums[r]=nums[r],nums[m]; r-=1 else: m+=1 |
| 7️⃣ | Container With Most Water | Two pointers, move shorter line inward. | python def maxArea(h): l, r, area = 0, len(h)-1, 0 while l<r: area = max(area, min(h[l],h[r])*(r-l)) if h[l]<h[r]: l+=1 else: r-=1 return area |
| 8️⃣ | 3Sum | Sort + fix one element + two-pointer search. | python def threeSum(nums): nums.sort(); res=[] for i,a in enumerate(nums): if i>0 and a==nums[i-1]: continue l,r=i+1,len(nums)-1 while l<r: s=a+nums[l]+nums[r] if s<0:l+=1 elif s>0:r-=1 else: res.append([a,nums[l],nums[r]]); l+=1; while l<r and nums[l]==nums[l-1]: l+=1 return res |
| 9️⃣ | Find Duplicate Number | Use Floyd’s cycle detection (linked list analogy). | python def findDuplicate(nums): slow, fast = nums[0], nums[0] while True: slow = nums[slow]; fast = nums[nums[fast]]; if slow==fast: break slow = nums[0] while slow!=fast: slow = nums[slow]; fast = nums[fast] return slow |
| 🔟 | Trapping Rain Water | Use two pointers, track left/right max walls. | python def trap(h): l,r=0,len(h)-1; lm=rm=water=0 while l<r: if h[l]<h[r]: lm=max(lm,h[l]); water+=lm-h[l]; l+=1 else: rm=max(rm,h[r]); water+=rm-h[r]; r-=1 return water |
⚙️ Tips for Mastery
| Focus Area | How to Practice |
|---|---|
| Two Pointers | Practice 2Sum, 3Sum, Container with Water, Sort Colors |
| Sliding Window | Try “Longest Substring Without Repeating Characters” |
| Prefix/Suffix | Product Except Self, Subarray Sum = K |
| Hashing | Two Sum, Subarray Sum problems |
| Greedy + DP | Kadane, Buy/Sell Stock |
Published on: Oct 09, 2025, 10:03 PM
Updated on: Oct 09, 2025, 10:06 PM