call(back)

Problems

Callback's own problems and the LeetCode questions companies have been asking, in one place — pick a category, then filter by company, frequency, status, difficulty, topic, and language.

Collect Pins from Reachable Boards

Algorithms & Data Structures · BFS over the bipartite pin-board graph without building board-to-board edges.

hardSign in to star problems

Compute Reachable Cells for a Cleaning Robot

Algorithms & Data Structures · Slide-until-blocked physics: rest positions are the states, not cells.

mediumSign in to star problems

Mark and Compact a Heap-Indexed Subtree

Algorithms & Data Structures · Garbage collection in miniature: mark a subtree, compact, remap.

mediumSign in to star problems

Bus Routes: Minimum Transfers

Algorithms & Data Structures · BFS over routes, not stops — clear each stop as you expand it.

hardSign in to star problems

Exact Board Jumps I

Algorithms & Data Structures · Two out-edges per index: a graph search with a visited array.

easySign in to star problems

Count Objects in a Pixel Grid via an API

Algorithms & Data Structures · Flood fill through an opaque API — isSameObject is the catch.

mediumSign in to star problems

Roads with Switches

Algorithms & Data Structures · Open roads cost 0, closed cost 1 — textbook 0-1 BFS.

mediumSign in to star problems

Shortest Path Around Obstacles

Algorithms & Data Structures · Unit steps on a grid: BFS, and the first arrival is the answer.

mediumSign in to star problems

Rod Cutting I

Algorithms & Data Structures · Unbounded knapsack in disguise — say that out loud, then roll a 1-D table.

mediumSign in to star problems

Course Schedule

Algorithms & Data Structures · Cycle detection dressed up as a scheduling question.

mediumSign in to star problems

Number of Islands

Algorithms & Data Structures · Flood fill from every unvisited land cell — and know when DFS, BFS or union-find fits.

mediumSign in to star problems

Unit Conversion I

Algorithms & Data Structures · One DFS from the base unit multiplies factors down the tree, modulo a prime.

mediumSign in to star problems

Sorted List to Balanced BST

Algorithms & Data Structures · Build in-order and pull values off a forward-only iterator — no middle-finding, no array copy.

mediumSign in to star problems

Capture Stones on a Go Board

Algorithms & Data Structures · A group dies exactly when it has no adjacent empty point — flood fill each neighbouring enemy group.

mediumSign in to star problems

Is Graph Bipartite?

Algorithms & Data Structures · Two-colour with BFS from every unvisited node; an odd cycle is the only way to fail.

mediumSign in to star problems

Word Ladder

Algorithms & Data Structures · BFS, not DFS — shortest path — then mention bidirectional BFS, which roughly square-roots the frontier.

hardSign in to star problems

Exact Board Jumps II

Algorithms & Data Structures · BFS from the start: the layer where the last index appears is the answer.

mediumSign in to star problems

Reverse Count-and-Say II

Algorithms & Data Structures · The reverse parse, memoized on (index, previous digit) — count, don't build.

hardSign in to star problems

Sensor Network III

Algorithms & Data Structures · Kahn's algorithm: peel sensors with no pending inputs; leftovers mean a cycle.

mediumSign in to star problems

Rod Cutting II

Algorithms & Data Structures · The rod-cutting table again, charging for every cut and seeding the whole-rod sale.

mediumSign in to star problems

Rod Cutting III

Algorithms & Data Structures · Add a piece-count dimension: dp[k][L] builds on dp[k − 1][L − p].

mediumSign in to star problems

Unit Conversion II

Algorithms & Data Structures · Convert through the base unit — and divide with a modular inverse, since you can't divide mod p.

hardSign in to star problems

Nearest Bathroom for Every Desk

Algorithms & Data Structures · Seed the queue with every bathroom and expand once — one BFS for the whole floor, not one per desk.

mediumSign in to star problems

People and Cakes II

Algorithms & Data Structures · Nearest-cake greedy is wrong; with both lists sorted, an optimal matching never crosses, so a 2-D DP finds it.

mediumSign in to star problems

Course Completion Time I

Algorithms & Data Structures · Courses run in waves, and a wave takes as long as its slowest course.

mediumSign in to star problems

Tree Height After Deletions II

Algorithms & Data Structures · Delete exactly the non-root nodes whose own subtree is k or more deep — one post-order pass, no DP.

hardSign in to star problems

Wiki Page Links I

Algorithms & Data Structures · BFS over an implicit graph, fetching each page exactly once.

mediumSign in to star problems

Wiki Page Links II

Algorithms & Data Structures · Store one predecessor per page, not a path per queue entry, and walk it back from the target.

mediumSign in to star problems

Wiki Page Links III

Algorithms & Data Structures · A BFS that keeps going after the target is gone — and the thread-safety story that comes with it.

mediumSign in to star problems

Course Completion Time II

Algorithms & Data Structures · A course may start once any one prerequisite is done: swap the max for a min and relax in topological order.

mediumSign in to star problems

Tree Height After Deletions I

Algorithms & Data Structures · A deleted node hands its children to its nearest surviving ancestor, so it simply adds no level.

mediumSign in to star problems

Most Credits With at Most K Classes

Algorithms & Data Structures · Weighted interval scheduling with a count budget: sort by end, binary-search the compatible predecessor, add a dimension for the cap.

hardSign in to star problems

Fewest Coins When Change Is Given

Algorithms & Data Structures · Overpaying can save coins: minimise coins handed over plus coins handed back, over every payment up to one large coin above the price.

mediumSign in to star problems

Reach a Target With +2, Double and Halve

Algorithms & Data Structures · Any sequence counts, so think constructively: +2 keeps parity, doubling then +2s then halving shifts it, and halving is how you get smaller.

mediumSign in to star problems

Count the Nodes of a Tree by Messages

Algorithms & Data Structures · A node asks every neighbour except the one that asked it, sums the replies plus one, and remembers answers so duplicates are harmless.

hardSign in to star problems

Pre-Order Traversal Skipping Marked Nodes

Algorithms & Data Structures · A pre-order walk with a stack; a marked node is dropped before its children are pushed, so its whole subtree disappears.

easySign in to star problems

Delete a Node From a Forest Stored as a Parent Array

Algorithms & Data Structures · Children of the deleted node are re-parented to its parent; a deleted root's children become roots.

easySign in to star problems

Rewrite Two Complete Trees With Subtree Sums

Algorithms & Data Structures · In array form the children of i are 2i + 1 and 2i + 2, so merge by index and accumulate sums from the last index down.

mediumSign in to star problems

Breadth-First Search Order

Algorithms & Data Structures · A queue with an index pointer, a visited set marked on enqueue, neighbours in the order given.

easySign in to star problems

Subtree Pruning I

Algorithms & Data Structures · Deleting a node takes its subtree: walk down from the root, never entering a deleted node, and keep the deepest level reached.

easySign in to star problems

Subtree Pruning II

Algorithms & Data Structures · When nodes within the limit must stay, the only cuts that can be made are the first nodes past it — and each is a separate cut.

easySign in to star problems

Subtree Pruning III

Algorithms & Data Structures · One cut per root branch that is too deep, placed at the deepest node above all of that branch's offending nodes.

mediumSign in to star problems

Boundary of a Full Binary Tree

Algorithms & Data Structures · With no missing children the two edges are plain spines: walk them and the leaves separately, and count the corners once.

mediumSign in to star problems

Longest Common Substring

Algorithms & Data Structures · A table that resets to zero on a mismatch, so the answer is the largest cell rather than the corner, and one row of it is enough.

mediumSign in to star problems

Topological Sort

Algorithms & Data Structures · Kahn's algorithm with a min-heap in place of the queue: in-degrees, a frontier of ready nodes, and an empty result when a node never becomes ready.

mediumSign in to star problems

Files and Folders Workspace

Algorithms & Data Structures · Create, list, delete and move resources in an in-memory tree: parent pointers for the upward checks, ordered child lists for the downward ones.

mediumSign in to star problems

Count Alternating-Parity Subarrays

Algorithms & Data Structures · Count the subarrays in which neighbours always differ in parity: the number ending at each index is the length of the current alternating streak.

easySign in to star problems

Count Path Sums in an N-ary Tree

Algorithms & Data Structures · Count downward paths that add up to a target when a node can have any number of children: a prefix-sum counter that is scoped to the current root-to-node path.

mediumSign in to star problems

Equalize Root-to-Leaf Sums in an N-ary Tree

Algorithms & Data Structures · Raise node values by one at a time until every root-to-leaf path has the same sum, using the fewest increments: lift each shortfall as high in the tree as it can go.

mediumSign in to star problems

Binary Tree Maximum Path Sum, With the Path

Algorithms & Data Structures · The maximum path sum is the warm-up; the follow-up wants the nodes on the path, which means recording which arm each node extends and stitching two arms together at the best bend.

hardSign in to star problems

Heaviest Set of Non-Adjacent Nodes

Algorithms & Data Structures · House Robber on an arbitrary small graph: with at most 20 nodes, a dynamic programme over subsets decides, for the lowest remaining node, take it and drop its neighbours or skip it.

mediumSign in to star problems

Count Islands on a Torus

Algorithms & Data Structures · Number of Islands where the top edge touches the bottom and the left edge touches the right: wrap the neighbour arithmetic, then discuss union-find and cell flips.

mediumSign in to star problems

Asked on LeetCode

864 questions tagged Tree or Breadth-First Search or Dynamic Programming · all time

Listings only — titles, difficulty, and tags link out to LeetCode. Imported from the leetcode-company-wise-problems snapshot dated 1 June 2025. Frequency is that dataset's own relative score within a company and time range.