Array Algorithms
Everything on SkillVeris tagged Array Algorithms — collected across the glossary, study notes, blog, and cheat sheets.
17 resources across 1 library
Interview Questions(17)
What is Selection Sort?
Selection sort repeatedly scans the unsorted portion of an array to find the minimum element and swaps it into place at the front, giving an O(n²) comparison-b…
What is Shell Sort?
Shell sort is an in-place comparison sort that generalizes insertion sort by first comparing and swapping elements far apart using a shrinking gap sequence, mo…
What is Bubble Sort?
Bubble sort repeatedly steps through an array comparing each pair of adjacent elements and swapping them if they are out of order, so on every full pass the la…
How Do You Find the Longest Increasing Subsequence?
The longest increasing subsequence (LIS) is the longest subsequence of an array in which elements strictly increase, solvable in O(n^2) with straightforward dy…
Minimum Window Substring: How Do You Solve It?
Minimum window substring is solved with a variable-size sliding window and two hash maps: expand the right pointer until the window contains every required cha…
Longest Substring Without Repeating Characters
The longest substring without repeating characters is found with a sliding window and a hash map that stores the last seen index of each character: expand the…
How Do You Solve the Valid Parentheses Problem?
The valid parentheses problem is solved with a stack: push every opening bracket you encounter, and on every closing bracket, check that the stack's top is the…
Next Greater Element: How Do You Solve It?
The next greater element problem is solved with a monotonic decreasing stack: scan the array left to right keeping the stack's values in decreasing order, and…
What is the Monotonic Stack Technique?
A monotonic stack is a stack that is kept either strictly increasing or strictly decreasing from bottom to top by popping any element that would violate that o…
What is the Monotonic Queue Technique?
A monotonic queue is a deque that keeps its elements in strictly increasing or decreasing order by evicting from the back any element that can never again be t…
How Do You Find the Median of Two Sorted Arrays?
The median of two sorted arrays can be found in O(log(min(m, n))) time by binary searching a partition point on the smaller array, choosing a matching partitio…
How Do You Find the Kth Largest Element in an Array?
The kth largest element can be found in average O(n) time using quickselect, a partition-based algorithm derived from quicksort that only recurses into the sid…
House Robber Problem: How Do You Solve It?
The house robber problem — maximizing loot from a row of houses without robbing two adjacent ones — is solved with dynamic programming where, at each house, yo…
Jump Game Problem: How Do You Solve It?
The jump game problem — determining if you can reach the last index of an array where each element is the maximum jump length from that position — is best solv…
What is the Sparse Table Technique?
A sparse table is a precomputed 2D array that answers range minimum, maximum, or GCD queries on a static array in O(1) time after O(n log n) preprocessing, by…
What is Mo's Algorithm?
Mo's algorithm answers many offline range queries on a static array efficiently by sorting queries into blocks of size sqrt(n) and moving a sliding [L, R] wind…
What is a Disjoint Sparse Table?
A disjoint sparse table is a variant of the sparse table that answers O(1) range queries for any associative operation — not just idempotent ones — by precompu…