0% found this document useful (0 votes)
37 views4 pages

Array Patterns

The document outlines five key array problem patterns commonly encountered in interviews, including Two Pointers, Binary Search, Sliding Window, Hashing/Frequency, and Prefix Sum. Each pattern includes when to use it, key signs to identify, and a list of ten example problems. This structured approach aids in recognizing and solving array-related challenges effectively.

Uploaded by

rohitpawar300803
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views4 pages

Array Patterns

The document outlines five key array problem patterns commonly encountered in interviews, including Two Pointers, Binary Search, Sliding Window, Hashing/Frequency, and Prefix Sum. Each pattern includes when to use it, key signs to identify, and a list of ten example problems. This structured approach aids in recognizing and solving array-related challenges effectively.

Uploaded by

rohitpawar300803
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ARRAY PROBLEM PATTERNS (Interview Focused)

1️⃣ Two Pointers Pattern (10 Problems)

When to use:

●​ Array is sorted​

●​ Need pairs / subarrays​

●​ Left–right movement​

Key sign: “find pair”, “remove duplicates”, “palindrome”, “sum”

Problems:

1.​ Two Sum II (sorted array)​

2.​ Remove Duplicates from Sorted Array​

3.​ Move Zeroes​

4.​ Reverse String​

5.​ Container With Most Water​

6.​ Valid Palindrome​

7.​ Squares of a Sorted Array​

8.​ Remove Element​

9.​ Trapping Rain Water​

10.​Sort Colors (Dutch National Flag)​

2️⃣ Binary Search Pattern (10 Problems)

When to use:
●​ Array is sorted​

●​ Find element / position / minimum / boundary​

Key sign: “sorted”, “log n”, “first/last position”

Problems:

1.​ Binary Search​

2.​ Search Insert Position​

3.​ First & Last Position of Element​

4.​ Find Peak Element​

5.​ Search in Rotated Sorted Array​

6.​ Find Minimum in Rotated Sorted Array​

7.​ Guess Number Higher or Lower​

8.​ Sqrt(x)​

9.​ Koko Eating Bananas​

10.​Capacity to Ship Packages Within D Days​

3️⃣ Sliding Window Pattern (10 Problems)

When to use:

●​ Subarray​

●​ Continuous elements​

●​ Max / Min / Sum / Count​

Key sign: “subarray”, “window”, “contiguous”

Problems:

1.​ Maximum Subarray​


2.​ Best Time to Buy and Sell Stock​

3.​ Longest Substring Without Repeating Characters​

4.​ Minimum Size Subarray Sum​

5.​ Longest Repeating Character Replacement​

6.​ Subarray Product Less Than K​

7.​ Max Consecutive Ones III​

8.​ Permutation in String​

9.​ Find All Anagrams in a String​

10.​Sliding Window Maximum​

4️⃣ Hashing / Frequency Pattern (10 Problems)

When to use:

●​ Counting​

●​ Duplicates​

●​ Frequency matching​

Key sign: “frequency”, “count”, “unique”

Problems:

1.​ Two Sum​

2.​ Contains Duplicate​

3.​ Majority Element​

4.​ First Unique Character in String​

5.​ Intersection of Two Arrays​

6.​ Valid Anagram​


7.​ Group Anagrams​

8.​ Subarray Sum Equals K​

9.​ Longest Consecutive Sequence​

10.​Top K Frequent Elements​

5️⃣ Prefix Sum Pattern (10 Problems)

When to use:

●​ Range sum queries​

●​ Multiple sum calculations​

Key sign: “range”, “sum between i and j”

Problems:

1.​ Range Sum Query – Immutable​

2.​ Subarray Sum Equals K​

3.​ Find Pivot Index​

4.​ Running Sum of 1D Array​

5.​ Product of Array Except Self​

6.​ Contiguous Array​

7.​ Find the Highest Altitude​

8.​ Matrix Block Sum​

9.​ Sum of All Odd Length Subarrays​

10.​Maximum Sum Circular Subarray​

You might also like