What is the two-pointer technique?
The two-pointer technique maintains two indexes that move through a sequence to avoid repeatedly scanning the same elements.
The question library
Explore practical questions, clear explanations, and code examples across developer technologies.
Showing 1909–1920 of 3610 questions
The two-pointer technique maintains two indexes that move through a sequence to avoid repeatedly scanning the same elements.
Sliding window maintains a contiguous range and updates its state as the left or right boundary moves.
Floyd's tortoise-and-hare algorithm uses a slow pointer moving one step and a fast pointer moving two steps.
Use a stack: push each opening bracket, and for every closing bracket verify that the stack is non-empty and its top is the matching opener.
Binary search applies when the search space is ordered or a monotonic condition allows half the candidates to be eliminated each step.
A recursive solution solves a problem by calling itself on smaller subproblems until reaching a base case.
BFS explores a graph level by level using a queue, marking nodes as visited when they are enqueued.
DFS explores a path as far as possible before backtracking, using recursion or an explicit stack.
Count each value with a hash map, then use a min-heap of size K or bucket the values by frequency.
Dynamic programming solves overlapping subproblems by storing their results, using memoization or tabulation.
A greedy algorithm makes a locally best choice at each step.
Compare time complexity, auxiliary memory, stability, and whether the algorithm is in-place.