FlashKeepers

Computer Science · College · College and University

Coding Interview Patterns

Two pointers, sliding window, fast and slow pointers, binary search variants, backtracking, monotonic stacks and bit manipulation tricks.

About this set

45 basic cards for College Computer Science. It opens with "Two-pointer technique definition" and "When is two-pointer approach useful?". Study it alongside the other College sets below.

45 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

Two-pointer technique definition
Show answerUse two pointers starting from different positions to solve array or list problems in O(n) time
When is two-pointer approach useful?
Show answerWhen finding pairs, removing elements, or comparing values in a sorted array in a single pass
How do pointers move in a sorted array two-pointer problem?
Show answerIf sum is too large, move right pointer left; if too small, move left pointer right
What does convergence mean in two-pointer?
Show answerThe left and right pointers move toward each other until they meet
Two-pointer example: find pair with target sum
Show answerPlace left pointer at start, right at end; move them based on whether current sum is less than or greater than target
How to handle duplicates in two-pointer approach?
Show answerSkip duplicate values by advancing pointer past all equal elements
Time complexity advantage of two-pointer
Show answerReduces time from O(n^2) brute force to O(n) with only one or two passes through data
Reverse array in place with two pointers
Show answerStart pointers at both ends, swap elements, move toward center until they meet
Sliding window technique definition
Show answerMaintain a window of consecutive elements that expands and contracts based on a condition
When to use sliding window?
Show answerFor subarray or substring problems where you need to find minimum, maximum, or optimal window matching a condition
Expand-contract pattern in sliding window
Show answerExpand window by moving right pointer until condition breaks, then contract by moving left pointer to restore condition
Common sliding window problems
Show answerLongest substring without repeating, minimum window substring, maximum sum subarray of fixed size
Data structure for tracking sliding window state
Show answerHash map to track character frequency or set to track distinct elements in current window
Time complexity of sliding window
Show answerO(n) because each element is visited at most twice, once by right pointer and once by left pointer
Find longest substring without repeating characters
Show answerUse sliding window with hash map tracking last seen index; move left pointer when duplicate found

30 more cards in the app

Study this set free