Forward Pointers
These pointers start at the same position and move to one direction. This approach is typically used in problems involving subarrays or subsequences where you need to keep track of a contiguous block of elements. For example, the problem of finding the longest substring with no repeating characters can be solved using this approach.
Forward Pointers technique is also as known as Sliding Window technique where each left pointer and right pointer proceeds in the same direction and the two pointers form windows
if this makes sense haha
There are Two Sub-categories for Forward Pointers.
-
Fixed Size
This means thewindow
size is fixed. -
Flexible Size
This means thewindow
size is changing according to the conditions.
Problem | Topic | Platform |
---|---|---|
Contains Duplicate II | Fixed Size | Leetcode |
Number of Sub Arrays of Size K and Avg Greater than or Equal to Threshold | Fixed Size | Leetcode |
Maximum Average Subarray I | Fixed Size | Leetcode |
Substrings of Size Three with Distinct Characters | Fixed Size | Leetcode |
Minimum Size Subarray Sum | Flexible Size | Leetcode |
Longest Substring Without Repeating Characters | Flexible Size | Leetcode |
Longest Substring with At Most Two Distince Characters | Flexible Size | Leetcode |
Remove Nth Node From End of List | Flexible Size | Leetcode |
Longest Repeating Character Replacement | Flexible Size | Leetcode |
Number Of Substrings Containing All Three Characters | Flexible Size | Leetcode |