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.

Round Numeric Strings I

Algorithms & Data Structures · Arbitrary-precision rounding — floats need not apply.

mediumSign in to star problems

Assign Pins to Shortest Columns

Algorithms & Data Structures · The masonry-layout greedy: shortest column wins, leftmost on ties.

mediumSign in to star problems

Experiment Buckets I

Algorithms & Data Structures · Meet new group sizes while disrupting as few buckets as possible.

mediumSign in to star problems

Maximize Boxes Stored Through One Entrance

Algorithms & Data Structures · Prefix-min ceilings plus an exchange-argument greedy.

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

Settle Debts I

Algorithms & Data Structures · Net the balances, then match debtors to creditors greedily.

mediumSign in to star problems

Team Photo I

Algorithms & Data Structures · Sort both teams, pair i-th against i-th, and try both orders.

easySign in to star problems

Surveillance Footage I

Algorithms & Data Structures · Interval greedy: extend coverage with the farthest-reaching clip that still connects.

mediumSign in to star problems

Boxed Sentences I

Algorithms & Data Structures · Greedy word wrap inside ASCII borders — never split a word, never start a line with punctuation.

easySign 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

Nth Node at Level L in a 0/1 Tree

Algorithms & Data Structures · Never build the tree — halve recursively, or read the answer off the parity of popcount(n − 1).

mediumSign in to star problems

Reservoir Sampling

Algorithms & Data Structures · One pass and O(k) memory: item i replaces a random slot with probability k/(i+1).

mediumSign in to star problems

Precision, Recall and F1

Algorithms & Data Structures · Three guarded divisions — and 0 wherever a denominator is 0.

easySign in to star problems

Basic Calculator II

Algorithms & Data Structures · One pass with a stack of signed terms; the trap is integer division truncating toward zero.

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

Parse an Integer Without parseInt

Algorithms & Data Structures · Sign, then digits through a lookup table, accumulating n * 10 + d — and NaN for anything else.

easySign in to star problems

Round Numeric Strings II

Algorithms & Data Structures · Split, round each value with string arithmetic, join — floats need not apply.

mediumSign in to star problems

Team Photo II

Algorithms & Data Structures · Only faced pairs matter: greedily match the smaller team into the larger.

mediumSign in to star problems

Team Photo III

Algorithms & Data Structures · The greedy match, written into two rows with empty slots.

mediumSign in to star problems

Fewest Towers to Cover Every Crossing

Algorithms & Data Structures · Greedy: place each tower as far right as the leftmost uncovered crossing allows.

mediumSign in to star problems

Distance Between Two Points

Algorithms & Data Structures · One formula for every dimension: the square root of the summed squared differences.

easySign in to star problems

Surveillance Footage II

Algorithms & Data Structures · The farthest-reach greedy again, remembering which clip won each round.

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

Token-Bucket Rate Limiter

Algorithms & Data Structures · Store (tokens, last seen) per key and refill lazily on each call — O(1) per key.

mediumSign in to star problems

Stratified Sampling with Largest-Remainder Allocation

Algorithms & Data Structures · Floor each proportional share, give leftovers to the largest remainders, sample within each stratum.

hardSign in to star problems

NDCG@k

Algorithms & Data Structures · Discount each graded relevance by log2(position + 2), then divide by the ideal ordering's DCG.

mediumSign in to star problems

Cohen's Kappa

Algorithms & Data Structures · Observed agreement corrected for the agreement two annotators would reach by chance.

mediumSign in to star problems

Unbiased pass@k

Algorithms & Data Structures · 1 − C(n − c, k) / C(n, k), computed as a running product so nothing overflows.

mediumSign in to star problems

Multiply Without *

Algorithms & Data Structures · Binary long multiplication: add the doubled multiple for every set bit — and double with +=, not a 32-bit shift.

easySign in to star problems

Array Products II

Algorithms & Data Structures · Each position multiplies its two successors, wrapping around the end with modular indices.

easySign in to star problems

Sum 1 to n Recursively

Algorithms & Data Structures · A base case at n <= 0 and one recursive call — then say where the call stack runs out.

easySign in to star problems

Square Root Without Math.sqrt

Algorithms & Data Structures · Binary-search the root in [0, max(1, x)] for a fixed number of rounds — an epsilon loop never ends for large x.

easySign in to star problems

An Exact Fibonacci Generator

Algorithms & Data Structures · An infinite generator over two BigInts — ordinary numbers lose precision past the 78th term.

easySign in to star problems

Boxed Sentences II

Algorithms & Data Structures · Each sentence wraps at its own width; one box pads every line to the widest.

easySign 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

Tiered Token-Bucket Limiter

Algorithms & Data Structures · Per-client (tokens, last seen), a tier config read on every call, and an explicit fallback for clients with no valid tier.

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

Minimum Bus Fleet

Algorithms & Data Structures · Meeting rooms with stations: a bus is reusable only where it arrived, so keep the idle buses per station.

mediumSign in to star problems

Pick the Query Type That Maximises Revenue

Algorithms & Data Structures · Committing to one type, you run it floor(k / duration) times; score every type and keep the best, earliest on ties.

easySign 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

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

People and Cakes V

Algorithms & Data Structures · One person, every cake: scan the grid once keeping the cake with the smallest Manhattan distance.

easySign 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

Happy Number Cycle

Algorithms & Data Structures · Iterate the digit-square sum until a value repeats; the loop is the path from that value's first visit, and a happy number's loop is just [1].

easySign in to star problems

Happy Numbers Up to N

Algorithms & Data Structures · One memo shared across every start: each value on a walk inherits the answer of where the walk stopped, so no value is followed twice.

easySign in to star problems

Assign Each Flight a Runway

Algorithms & Data Structures · Runways are workers and flights are tasks: a heap of free times hands each flight, in start order, to the runway that frees up first.

mediumSign in to star problems

Rank Vectors by Cosine Similarity

Algorithms & Data Structures · Score every candidate against the query, keep the indices with the scores, sort descending; the zero vector needs a defined answer.

easySign in to star problems

When Do the Chasing Points Meet?

Algorithms & Data Structures · N points in a cycle each move at unit speed toward the next one; simulate with a step small enough that the meeting time is right to the hundredth.

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

Validated Add-Subtract Calculator

Algorithms & Data Structures · Evaluate digits joined by + and - only after proving the string is well formed: no stray characters, no leading zeros, no doubled operators, and everything inside 32 bits.

mediumSign in to star problems

Largest Number Below a Limit From Allowed Digits

Algorithms & Data Structures · Keep the limit's prefix as long as possible, step one digit down, then fill with the largest allowed digit; fall back to a shorter number, and mind leading zeros.

mediumSign in to star problems

Subarray With the Largest Min Plus Max

Algorithms & Data Structures · It looks like a sliding-window problem and is not one: the best subarray of length two or more is always an adjacent pair.

easySign in to star problems

Fish From Decaying Ponds

Algorithms & Data Structures · Each hour fished lowers a pond's next yield by one. The heap greedy is the first answer; the accepted one finds the water line all ponds are fished down to and sums arithmetic series.

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

All Valid Expansions of Wildcard Parentheses

Algorithms & Data Structures · The follow-up to the wildcard validity check: enumerate every distinct balanced string the stars can produce, pruning on the running balance.

mediumSign 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

Asked on LeetCode

1,066 questions tagged Greedy or Math or Tree · 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.