A Swift concurrency type that protects its mutable state by allowing only one task at a time to touch it. Instead of manually guarding access with locks, you isolate the state behind the actor and interact with it through `await`ed methods.
Example: An image cache actor can serialize reads and writes so two tasks never mutate the same dictionary at once. The caller uses `await cache.image(for:)` instead of reaching into shared state directly.
Some operations are expensive, but they happen rarely. Amortized means you spread those rare costs across all the cheap operations and ask what one operation costs on average over time.
Example: ArrayList.add() is O(1) amortized: most inserts are cheap, and the occasional resize gets spread across many inserts.
Automatic Reference Counting — Swift's memory management system that tracks how many strong references point at an object and deallocates it when that count hits zero. ARC is why `weak` and `unowned` exist: they change ownership so reference cycles do not keep objects alive forever.
Example: A view model and service that strongly reference each other never deallocate under ARC. Mark one side `weak` and ARC can drop both objects when the feature goes away.
A word for what happens when the input gets huge. It tells you to ignore tiny constants and focus on the growth shape: does the work grow like n, n log n, n squared, or something worse?
Example: Two solutions may both pass for n = 20. Asymptotic analysis asks which one still survives when n = 200,000.
An OS-scheduled wake-up that lets your app refresh data on its own cadence, without the user opening it. The schedule is the systems call, not yours — roughly every fifteen minutes on power, far less on battery — so design for unpredictable, infrequent runs rather than a reliable timer.
Example: A news app registers for background fetch so the morning headlines are already cached when the user unlocks their phone. On a low battery the OS may skip several cycles, so the app still refreshes on foreground.
Operations that act on the individual bits of a number (`&`, `|`, `^`, `~`, `<<`, `>>`) rather than the number as a whole. Faster than arithmetic and often unlocks tricks regular math can't — like toggling a flag without a branch, or testing a property in a single comparison.
Example: `n & (n - 1)` clears the lowest set bit, so 'is n a power of two?' becomes `n > 0 && (n & (n - 1)) == 0` — one bitwise op instead of a loop.
xorbit-maskbinary-representation Keeping a copy of expensive work so you don't redo it. A hash map remembering computed results, a CDN serving static files, Redis standing in for a slow database query — they're all caches. The hard part isn't storing the copy. It's knowing when the copy goes stale and who's allowed to invalidate it.
Example: Looking up a user's avatar on every request hits the DB. Caching it in Redis with a 60s TTL drops that from one DB round-trip per request to roughly one per minute — at the cost of a 60s window where avatar changes don't show up.
The standard version people usually mean. A canonical problem, solution, or example is not the only possible one. It is the version the room expects you to recognize.
Example: Sliding Window Maximum is the canonical monotonic deque problem. Learn that shape and the smaller variants feel less mysterious.
Finding whether a graph or linked list loops back on itself. In a linked list, use Floyd's tortoise and hare (slow + fast pointer). In a directed graph, use DFS with a 'currently visiting' state.
Example: Linked List Cycle: slow pointer moves 1 step, fast moves 2. If they meet, there's a cycle.
A bug where two concurrent pieces of code access the same mutable state at the same time and at least one access is a write. The bad part is not just wrong data — it is non-determinism. The same code can pass once and fail later with no visible input change.
Example: One task increments `count` while another reads and writes it on a different thread. Sometimes the final value is right, sometimes an update disappears. That's a data race.
A graph with directed edges and NO cycles. The foundation for dependency resolution, build systems, and topological sorting. If you can draw it without any arrows forming a loop, it's a DAG.
Example: Course prerequisites form a DAG: CS101 → CS201 → CS301. No course can be its own prerequisite (no cycle).
Break a problem into overlapping subproblems, solve each once, and build up to the final answer. The key question: 'what does the future need to know from the past?' If you can define that, you can write the recurrence.
Example: Climbing stairs: ways(n) = ways(n-1) + ways(n-2). Each step only needs the two before it.
A guarantee that replicas converge to the same value eventually — not instantly. Writes propagate in the background, so for a short window different readers can see different values. You give up read-your-writes immediacy to get availability and partition tolerance, which is the right trade for most consumer apps.
Example: Post a comment, refresh on another device a second later, and it is not there yet — then it appears. The system was eventually consistent, not strongly consistent.
When two different keys produce the same hash value and land in the same bucket. Every hash table has to handle this — usually by chaining (linked list in the bucket) or open addressing (probe to the next empty slot).
Example: If hash('cat') = 7 and hash('dog') = 7, both go to bucket 7. The hash table chains them together.
Safe to retry because doing it twice gives the same final result as doing it once. Setting a value to 5 is idempotent. Incrementing by 1 is not.
Example: PUT requests are idempotent (replace the resource). POST requests are not (create a new one each time).
api-designretry-safetyexactly-once
Something that keeps moving in one direction: nondecreasing or nonincreasing. A monotonic stack keeps that order by popping values that would break it.
Example: A monotonic decreasing stack: [8, 5, 3]. Push 6? Pop 5 and 3 first, then push 6. Now it's [8, 6].
Cutting off branches of your search tree early because you KNOW they can't lead to a valid answer. Without pruning, backtracking checks every possibility. With pruning, it skips entire subtrees. The difference between TLE and AC.
Example: N-Queens: if placing a queen on row 3 column 2 conflicts with row 1, skip ALL arrangements that build on that placement.
A formula that defines each value in terms of previous values. It is the mathematical backbone of dynamic programming. If you can write the recurrence, you can write the code.
Example: Fibonacci: F(n) = F(n-1) + F(n-2). Climbing stairs: same recurrence, different story.
A memory leak where two or more objects keep strong references to each other, so ARC never reaches zero and nothing deallocates. The usual Swift interview trap is a closure capturing `self` while `self` also owns the closure.
Example: A service stores `onUpdate`, the closure captures `self`, and the view model owns the service. That loop keeps all three alive until you break the cycle with `[weak self]`.
arcweak-referenceunowned-reference A Swift concurrency protocol that marks a value as safe to move across actor or task boundaries. If a type is `Sendable`, the compiler can trust that passing it between concurrent contexts will not smuggle shared mutable state and create a race.
Example: A struct of plain value types often gets `Sendable` for free. A class with mutable properties usually does not, which is why the compiler starts complaining when you pass it into a `Task`.
A dummy node at the head or tail of a linked list that simplifies edge cases. Instead of special-casing 'what if the list is empty?' or 'what if I'm inserting at the head?', the sentinel is always there, so every real node has a predecessor.
Example: LRU Cache: use a dummy head and dummy tail. Every real node sits between them. No null checks needed.
A push notification with no visible alert whose only job is to wake your app in the background so it can fetch fresh data. The OS rate-limits these hard, and a dropped one is normal — so treat silent push as an opportunistic sync trigger, never as a guaranteed delivery channel.
Example: A chat app sends a silent push when a new message lands; the app wakes, pulls the thread, and updates the badge before the user ever opens it. If the OS throttles the push, the next foreground sync still catches up.
A sort that preserves the original order of elements with equal keys. Merge sort is stable. Quick sort is not. This matters when you sort by multiple criteria — sort by name first, then by age, and a stable sort keeps the name order within each age group.
Example: Sort students by grade, then by name. Stable sort preserves alphabetical order within the same grade.
merge-sortquick-sortcomparison-sort
A cache policy that serves the old copy instantly while fetching a fresh one in the background. The user never waits on the network for already-seen data; the next render quietly gets the update. It trades a brief window of staleness for a UI that always feels immediate.
Example: Open a profile screen: the cached avatar and name paint in zero milliseconds, a refresh request fires in the background, and if the data changed the screen reconciles on the next frame.
The round where the interviewer hands you a vague product goal ('design Twitter', 'design a rate limiter') and watches how you decompose it into components, pick trade-offs, and defend your choices. Not about memorizing architectures — it's about whether you can reason about capacity, consistency, latency, and failure without reaching for jargon.
Example: 'Design a URL shortener for 100M daily active users.' Strong answer starts with back-of-envelope math (QPS, storage, read:write ratio), picks a primary key strategy (base62 hash vs counter), discusses the cache layer, and names the SPOFs. Weak answer jumps straight to 'I'd use Redis and Kafka.'
capacity-planningtrade-offconsistency
A way to line up tasks so every dependency comes before the thing that depends on it. If course B requires course A, A appears first in the topological order. Only works on directed graphs with no cycles.
Example: Course Schedule on LeetCode: can you take all courses given their prerequisites? That's topological sort.
directed-acyclic-graphdependencykahns-algorithm
A tree where each node represents a character, and paths from root to nodes spell out words. Incredible for prefix-based lookups — 'is any word in my dictionary that starts with pre-?' takes O(length) time regardless of dictionary size.
Example: Autocomplete: type 'app' → the trie instantly gives you 'apple', 'application', 'append'.
A data structure that tracks which elements belong to the same group. Two operations: UNION (merge two groups) and FIND (which group does this element belong to?). With path compression and rank, both are nearly O(1).
Example: Number of Connected Components: union every edge, then count how many distinct roots remain.
disjoint-setconnected-componentspath-compression
Exclusive-or — a bitwise operator that returns 1 where two bits differ and 0 where they match. The interview-critical properties: `a ^ a = 0` (a thing cancels itself), `a ^ 0 = a` (zero is identity), and XOR is commutative/associative (order doesn't matter). XOR-ing a whole list in any order collapses every duplicate to 0.
Example: Single Number (LC 136): XOR every element in the array. Duplicates pair off and cancel, leaving only the unique number — O(n) time, O(1) space, no hash map.