What are the trigger words associated with substring/subarray problems?
These words indicate the need to find contiguous sequences within a data structure.
What pattern is commonly used for substring/subarray problems?
Sliding Window
This pattern helps in efficiently managing the current window of elements being considered.
What data structures are used for finding duplicates/repeating?
Sets allow for O(1) lookup to check for existing elements.
What are the trigger words for sum problems?
These phrases indicate the need to find pairs or groups of numbers that sum to a specific target.
What pattern is used for valid/balanced problems?
Stack
The stack’s LIFO structure is suitable for matching opening and closing elements.
What are the trigger words for counting/frequency problems?
These phrases indicate the need to analyze the frequency of elements.
What data structure is commonly used for counting/frequency problems?
The defaultdict or Counter from collections can simplify counting tasks.
What are the trigger words for interval problems?
These words indicate the need to manage and manipulate ranges of values.
What pattern is used for tree level/layer problems?
BFS
Breadth-First Search is effective for exploring tree levels.
What approach is commonly used for tree path problems?
Recursion
This approach allows for depth-first traversal of tree paths.
What are the trigger words for all combinations/permutations?
These phrases indicate the need to generate all possible arrangements of elements.
What pattern is used for finding in sorted arrays?
Binary Search
This pattern employs a divide and conquer strategy to efficiently locate elements.
What are the trigger words for top K/Kth largest problems?
These phrases indicate the need to find specific ranked elements within a dataset.
What pattern is used for maximum/minimum subarray problems?
Kadane’s Algorithm or Sliding Window
These methods help in efficiently calculating maximum or minimum sums of contiguous subarrays.