Daily signal total
A career dashboard receives n signed activity changes. Return their total without changing their order or values.
RESUMEWORLDS / ORIGINAL QUESTION LIBRARY
200 coding exercises with authored examples and private grading cases, plus 50 system-design scenarios with constraints and failure rounds.
Download public question bankPublic links share question material. Your code, drafts, interview history, hidden tests and reference implementations stay private. Coding execution requires a configured isolated runner.
Editorial practice collections
Original exercises mapped to public guidance. Company-style relevance does not mean a company asked these questions.
Company-style selections are editorial practice suggestions. View topics and source →
250 of 250 original questions
A career dashboard receives n signed activity changes. Return their total without changing their order or values.
Visitor IDs may repeat in the practice log. Count how many distinct integer IDs occurred.
Daily momentum can rise or fall. Find the maximum sum of a nonempty contiguous segment of the daily changes.
Count index pairs i < j whose activity costs add to the target budget. Equal values at different indexes count separately.
Given sorted availability scores, return the zero-based index of the first score at least the target. Return n if none qualifies.
Review n positive workloads in order across at most d days. Each day takes a contiguous group. Find the smallest daily capacity that can complete every workload.
Each activity is labeled by an integer topic ID. Find the longest contiguous window containing at most k distinct topics.
Positive IDs open actions; negative IDs close the matching positive ID. Actions must close in reverse opening order. Print 1 if the entire sequence is correctly nested and fully closed, otherwise 0.
Mentoring sessions use half-open intervals [start, end). Find the minimum number of rooms needed. A room ending at time t can be reused by a session starting at t.
Given an undirected unweighted graph, return the fewest edges from source to target, or -1 if unreachable. Duplicate edges and self-loops are allowed.
You have unlimited tokens of each given positive value. Return the fewest tokens needed to total exactly the target, or -1 if impossible.
Find the length of the longest strictly increasing subsequence of milestone scores. A subsequence preserves order but may skip entries; equal scores do not extend it.
Walls have unit width and nonnegative integer heights. Return the total water trapped after rain.
Return the second largest DISTINCT score, or -101 if fewer than two distinct scores exist.
Count pairs i < j for which value[i] > value[j]. Equal values do not count.
Return the topic ID occurring strictly more than n/2 times, or -101 if no such ID exists.
The n supplied IDs are distinct members of 0..n. Return the one missing ID.
Return the smallest positive integer absent from the supplied values.
Swap any two positions per move. Find the fewest swaps needed to place all 1 flags in one contiguous group. Return 0 when there are no 1 flags.
Buy once and later sell once, or do nothing. Return the maximum nonnegative gain from the daily prices.
Buy and sell repeatedly but hold at most one unit at a time. No fees or cooldown apply. Return the greatest total gain.
Return the length of the smallest contiguous segment whose sorting makes the whole array nondecreasing. Return 0 if already sorted.
Return the largest product of a nonempty contiguous segment. Zeros and negative values are allowed.
Return the length of the longest run of consecutive distinct integer values, regardless of their input order.
Count nonempty contiguous segments whose sum equals the target.
Return the minimum length of a nonempty contiguous segment whose sum is at least target; return 0 if none qualifies.
Count nonempty contiguous segments whose product is strictly below k.
Count nonempty contiguous segments containing exactly k distinct values.
Return the longest contiguous span containing equally many zeros and ones.
Flip at most k zero flags into ones. Return the longest achievable contiguous one streak.
Return the maximum sum among contiguous windows of exactly k values. Negative sums remain negative.
A strictly increasing array was cyclically rotated. Return the zero-based target index, or -1 if absent.
Return the smallest value of a rotated strictly increasing array.
Values strictly increase then strictly decrease, with the summit strictly inside the array. Return its zero-based index.
Merge two nondecreasing logs conceptually. Return the k-th smallest value, with k one-based. Duplicates count separately.
Return floor(sqrt(x)) without requiring floating-point root operations.
Each hour processes at most rate units from one workload; leftover hourly capacity is not shared. Find the minimum positive integer rate finishing all workloads within h hours.
Return TWICE the median of two nondecreasing arrays, so the output remains an integer. For even length add the two central values; for odd length double the central value.
Each bar has width one. Return the largest rectangular area lying completely under consecutive histogram bars.
For each reading, wait until the first later STRICTLY larger reading; if none exists, its wait is zero. Return the sum of all index waits.
Count pairs i<j that can see each other: every intermediate height must be strictly below min(height[i],height[j]). Adjacent rooftops always qualify.
For every nonempty contiguous segment take its minimum. Return the sum of these minimums.
Take the maximum of each length-k contiguous window and return the sum of these maxima.
Evaluate a valid postfix expression. Operands are integers -10..10; tokens 101,102,103 mean addition, subtraction and multiplication. Subtraction uses left operand minus right operand.
Tokens 1 and -1 mean open and close brackets of one kind. Return the fewest bracket insertions needed to make the entire sequence balanced.
Given a valid balanced bracket sequence encoded as 1=open and -1=close, return its maximum nesting depth.
Return the length of the longest contiguous VALID balanced bracket segment encoded as 1=open and -1=close. Balanced totals alone do not ensure valid prefixes.
Each command pair is (1,x) to enqueue x or (2,0) to remove the front if present. Return the final front, or -101 for an empty queue.
Return the greatest positive integer dividing every supplied positive batch size.
Count index pairs i<j whose positive values have greatest common divisor 1.
Count prime integers in the inclusive range 0..x.
Return the number of trailing decimal zeros in x!, with 0!=1. Do not construct the factorial.
Return base^exponent modulo modulus. Define exponent zero as yielding 1 before taking the modulus.
Count unordered ways to choose exactly r different people from n. Return 0 for r>n. People are distinct and order does not matter.
Return the minimum number of positive perfect squares that sum to x. Squares may repeat; x=0 needs zero tokens.
Add the number of one bits in the binary representation of every integer from 0 through x, inclusive.
Repeatedly replace a positive integer with the sum of squares of its decimal digits. Print 1 if this reaches 1, otherwise 0 when a cycle repeats.
Return the length of the longest nonempty contiguous palindromic glyph sequence.
Count all nonempty palindromic contiguous glyph sequences. Equal content at different indexes counts separately.
Partition the glyph sequence into contiguous palindromes. Return the fewest cuts between parts.
Return the fewest single-glyph insertions, deletions and substitutions converting the first sequence to the second. Every operation costs one.
Return the length of the longest sequence that is a subsequence of both inputs. Subsequence order is preserved but indexes may be skipped.
Return the length of the longest contiguous glyph block occurring in both inputs. Skipping characters is not allowed.
Count indexed subsequences of the first input equal to the second input. Return the count modulo 1,000,000,007.
Return the shortest contiguous source window containing every target glyph with at least its target multiplicity. Return 0 if no covering window exists.
Count contiguous source windows that are permutations of the target glyph sequence, including target multiplicities.
Compress each consecutive run as one glyph plus the decimal run count when the run is longer than one. Return the resulting encoded length; the glyph always occupies one symbol.
Return the length of the longest contiguous glyph sequence with no repeated glyph.
A=1 through Z=26. Count ways to decode the full digit sequence. Zero cannot stand alone; a pair may not begin with zero. Return the count modulo 1,000,000,007.
Start at the top-left and move only right or down to the bottom-right. Zero cells are open and one cells blocked. Count routes modulo 1,000,000,007; blocked endpoints yield zero.
Move right/down from top-left to bottom-right. Return the minimum total charge including both endpoints.
One cells are land. Count connected land components using four-side adjacency.
Return the cell count of the largest four-side connected land component, or 0 if no land exists.
Return the number of land-cell sides touching water or outside the grid. Multiple islands and enclosed water are allowed.
Cells encode 0=open, 1=blocked, 2=start and 3=exit. Return the fewest four-side moves from start to exit, or -1 if unreachable.
For each cell measure the fewest four-side moves to any zero cell; one cells are walkable. Return the sum of these distances.
Return the area of the largest axis-aligned square containing only one cells, or 0 when no land exists.
Return the maximum number of edges from root 0 to any node. A single-node tree has height 0.
Count nodes with no children in the rooted tree, including the root when it is the only node.
Nodes have signed weights. Return the maximum sum on a ROOT-TO-LEAF path, including endpoints. Do not stop early at an internal node.
Return the greatest edge distance between any two nodes of the tree. Direction from parents does not constrain the path.
Select as few tree nodes as possible so every parent-child edge has at least one selected endpoint. Return the minimum selected-node count.
Print 1 if the supplied binary tree satisfies strict BST ordering, otherwise 0. Every value in a left subtree must be smaller and every value in a right subtree larger; duplicates invalidate it.
Count connected components of the undirected graph, including isolated vertices.
Print 1 if vertices can be colored with two colors so every undirected edge joins different colors; otherwise 0. Self-loops invalidate it.
Print 1 if the undirected multigraph contains a cycle, otherwise 0. A self-loop is a cycle; two parallel edges form a cycle.
Edges are directed. Print 1 if a directed cycle exists, otherwise 0.
Count vertex permutations in which every directed edge u→v places u before v. Cyclic inputs have zero orders.
Every directed edge points from a smaller vertex ID to a larger one. Return the longest path’s number of edges, allowing any start and end.
Return the cheapest directed source-to-target route cost, or -1 if unreachable. Source equals target has cost zero.
Edges are undirected. Return the cheapest total edge cost connecting all vertices, or -1 if impossible. A one-vertex network costs zero.
Find the cheapest directed route using AT MOST k edges, not k intermediate stops. Return -1 if none qualifies.
Count vertices whose removal, including incident edges, increases the number of connected components of the UNDIRECTED graph. Compare with the original component count.
Count undirected edges whose individual removal increases the connected-component count. Parallel edges are separate: removing one may leave another route.
Count strongly connected components of a directed graph. Every pair of vertices within one group can reach each other.
Assign left-side learners to compatible right-side mentors. Each learner and mentor may appear in at most one assignment. Return the maximum assignment count.
Select as many sessions as possible with no overlap. Sessions are half-open [start,end), so touching endpoints are compatible.
Each job takes one time slot and earns its nonnegative reward only if completed by its integer deadline. Slots are numbered from one. Return maximum total reward; a job can run at most once.
Merge any two positive log sizes for cost equal to their sum; the merged log has that size. Repeat until one log remains. Return the minimum total cost.
Each station supplies fuel and has a cost to travel to the next station, with the last wrapping to zero. Start with an empty tank. Return the smallest zero-based start index completing one full loop without a negative tank, or -1.
An initially empty cache holds at most capacity keys. Every request makes its key most recently used. A missing key counts as one miss and is inserted, evicting the least recently used key if full. Return the miss count.
Process nondecreasing request timestamps. Admit a request only if fewer than limit previously ADMITTED requests lie in (time - window, time]. Rejected requests do not consume capacity. Equal timestamps are distinct requests. Return the admitted count.
Deliver the first notification for each user. Deliver another only when at least cooldown time has passed since that user’s last DELIVERED notification. Ignored notifications do not restart cooldown. Return the delivered count.
Start with n zero-valued slots. Each update adds a nonnegative amount to every slot in the inclusive range [left,right]. Return the largest final slot value.
A hiring panel recorded n interview scores for one candidate pool. Report the spread: the highest score minus the lowest score. With a single score the spread is 0.
A mock-test batch produced n integer scores. Count how many scores are strictly greater than the exact average of all n scores. A score equal to the average does not count, and the average may be a fraction.
Your daily practice minutes are listed in order. Find the length of the longest block of consecutive days in which every day is strictly higher than the day before it. A single day is a run of length 1, and equal days break a run.
A headline is encoded as glyphs: 1 to 26 stand for the letters a to z and 0 stands for a space. Ignoring every space, print 1 if the letters read the same forwards and backwards, otherwise 0. A headline with no letters counts as a mirror and prints 1.
A profile keyword is encoded as glyphs 1 to 26 for the letters a to z. Count how many glyphs are vowels, meaning a, e, i, o or u (glyphs 1, 5, 9, 15 and 21). Repeated vowels each count.
A learning app turns a nonnegative integer x into a single-digit badge code: while the number has two or more decimal digits, replace it with the sum of its digits. Return the final single digit. The code for 0 is 0.
Two access profiles are stored as nonnegative integers whose binary bits are permission flags. Count the bit positions at which the two profiles differ.
At a campus hiring event every badge ID was scanned exactly twice, once at entry and once at exit, except for one badge that was scanned only once. Return that badge ID. Scans are not in any particular order.
A build system prefers batch sizes that are exact powers of two (1, 2, 4, 8 and so on). Count how many of the n proposed batch sizes are powers of two. Zero and negative sizes never qualify.
Sprint story points are listed in order. Find the smallest zero-based index p such that the total of the points strictly before p equals the total strictly after p. An empty side totals 0. Return -1 if no such index exists.
A learning tracker stores n signed daily point changes. It then answers q queries, each asking for the total of the days from index l to index r inclusive (zero-based). Return the sum of all q answers; with no queries return 0.
A candidate skill list and a job requirement list are both given as skill codes in nondecreasing order, and codes may repeat. Match codes one-to-one: each occurrence can be matched with at most one equal occurrence in the other list. Return the largest number of matches.
Several reviewers each rated the same resume. Return the smallest absolute difference between the ratings of two different reviewers (two different positions). Equal ratings give a difference of 0.
One habit reminder fires on days a, 2a, 3a and so on, and another fires on days b, 2b, 3b and so on. Count the days from 1 to x inclusive on which at least one reminder fires. A day when both fire counts once.
Each practice session is tagged with an integer topic code. Return the code that appears most often. If several codes tie for the highest count, return the smallest of them.
Job application IDs arrive one at a time. Return the first ID that arrives for a second time, that is, the repeat occurring at the earliest position. Return -1 if every ID is different.
Each interviewer has an integer score weight. Count the ways to pick three different positions i < j < k whose weights add up exactly to the target. Equal values at different positions are different picks.
Partitions stand at positions 0 to n-1 with given nonnegative heights. Choosing two partitions i < j forms a bay whose capacity is (j - i) multiplied by the shorter of the two heights; partitions between them are ignored. Return the largest capacity.
Given signed daily point changes and a positive k, count the nonempty contiguous segments whose total is a multiple of k. A total of 0 counts, and negative totals such as -k also count.
A shared calendar holds n bookings as half-open time ranges [start, end). Bookings may overlap, touch or be empty (start equals end). Return the total amount of time covered by at least one booking, counting overlapping time only once.
Each build is described by a nonnegative feature mask. For two different positions, their distinctness is the bitwise XOR of the two masks. Return the largest distinctness over all pairs.
One move raises or lowers a single rating by exactly 1. Return the fewest moves needed to make all n ratings equal. The final common value may be any integer.
Each of your n portfolio projects has an endorsement count. Your index is the largest h such that at least h projects each have h or more endorsements. Return the index; it is 0 when no project is endorsed.
Tickets are numbered 1 to x and printed in plain decimal without leading zeros. Return how many times the digit d is printed in total. Every occurrence counts, so ticket 11 prints the digit 1 twice.
A campus locker code is a set of k different digits chosen from 1 to 9; the order in which the digits are written does not matter. Count the codes whose digits add up exactly to s.
An old attendance export glued p numbers together into one run of n decimal digits and lost the separators. Count the ways to cut the run into exactly p nonempty consecutive parts so that every part is a number from 0 to limit written without a leading zero. A part that is exactly 0 is allowed, but a part such as 05 is not.
A workshop agenda is a row of n opening markers and n closing markers. It is balanced when, reading left to right, the closings never outnumber the openings so far and both counts finish equal. Its depth is the largest number of markers that are open at the same moment. Count the balanced agendas with exactly n pairs whose depth is at most d.
Panel speakers are numbered 1 to n by seniority. A running order lists every speaker exactly once. To avoid back-to-back speakers of similar seniority, any two speakers who appear next to each other must have numbers that differ by at least d. Count the valid running orders.
A campus store has n gift vouchers with positive values, and several vouchers can share a value. Each voucher can be used at most once. Count the different collections of voucher VALUES that add up exactly to the target. Two collections are the same when they contain every value the same number of times, no matter which physical vouchers were used.
An n by n office floor plan marks each desk as usable (0) or blocked (1). Place exactly n security guards on usable desks so that no two guards share a row, a column or either diagonal direction. Blocked desks cannot hold a guard but do not interrupt a line of sight. Count the valid placements.
An interview coordinator has n interviews, each with a positive length in minutes, and k interviewers. Every interview goes to exactly one interviewer, in any combination, and an interviewer may receive none. An interviewer day length is the total minutes of their interviews. Return the smallest possible length of the longest interviewer day.
Release build numbers are stored in nondecreasing order, and the same build number can appear several times when a release was re-deployed. Return the zero-based index of the LAST occurrence of the target build number, or -1 when the target never appears.
A warehouse planner wants to stack unit boxes into the largest solid cube possible using at most x boxes. Return the largest integer side length r ≥ 0 with r * r * r ≤ x. Solve it with integer arithmetic rather than a floating-point cube-root function.
Help desks sit at strictly increasing integer positions along a training campus road. You may open at most k new desks at any integer positions. Return the smallest possible length of the longest stretch between neighbouring desks. Only the road between the first and last existing desk matters, and with a single desk the answer is 0.
A recruiter has n open time slots, given as distinct integer minutes in no particular order, and must book exactly c interviews in c different slots. Choose the slots so that the smallest gap between any two booked interviews is as large as possible, and return that smallest gap.
Ticket numbers handed out at a career fair are positive and strictly increasing, but some numbers were skipped by the printer. Return the k-th smallest positive integer that does NOT appear in the list. Missing numbers can lie beyond the last ticket.
Mentors are linked in a chain: each node stores a mentor rating and the index of the next node. The chain order is the order reached from head by following next, which can differ from index order. Return the rating stored in the middle node of the chain. When the chain has an even number of nodes, use the second of the two middle nodes.
Feedback scores are stored as linked nodes, each holding a score and the index of the next node. Only the order reached by following next from head matters, not the index order. Print 1 if the scores read the same from head to tail as from tail to head, otherwise print 0.
A referral tracker stores n nodes, each holding only the index of the next node, or -1 when there is none. Start at the head node and keep following next. Either the walk reaches -1, or it eventually repeats nodes forever around a loop. Return the number of nodes in that loop, or 0 if the walk ends. Nodes that cannot be reached from head are ignored.
A learning playlist is a linked chain of lessons; each node stores a lesson code and the index of the next node. Reverse the order of the lessons at chain positions left through right (1-based positions along the chain, inclusive) and leave every other lesson where it is. Then return the checksum of the new chain: the sum over every position p of p times the lesson code at that position.
Two referral chains live in one pool of n nodes, where each node stores only the index of its next node (-1 ends a chain). Chain A starts at headA and chain B starts at headB. Once the chains reach a common node they share every node after it. Return the index of the first node that belongs to both chains, or -1 if they never meet. If both heads are the same node, that node is the answer.
A sprint board stores task cards as a linked chain; each node holds a card value and the index of the next node. Walking from head, split the chain into consecutive groups of k cards. Reverse the order inside every complete group, and keep a final group of fewer than k cards in its original order. Return the checksum of the resulting chain: the sum over 1-based positions p of p times the card value at that position.
A reviewer keeps a stack of score cards and processes a log of operations. (1, x) pushes a card with score x. (2, 0) removes the top card if the stack is not empty and otherwise does nothing. (3, 0) asks for the lowest score currently on the stack. Return the sum of the answers to all lowest-score questions, where a question asked on an empty stack contributes 0. Aim for constant time per operation.
Courses are listed in order with integer prices. Each course is discounted by the price of the first course listed after it whose price is less than or equal to its own. A course with no such later course gets no discount. Return the total amount paid for all courses after the discounts.
A help desk runs its first-in-first-out ticket queue on two stacks, an inbox and an outbox. Adding a ticket pushes it onto the inbox. Serving a ticket pops the top of the outbox; if the outbox is empty at that moment, every ticket in the inbox is first popped and pushed onto the outbox, one ticket at a time. Serving when both stacks are empty does nothing. Return the total number of tickets moved from the inbox to the outbox over the whole log.
A notes editor holds a sequence of numbers and processes a log. (1, x) appends x to the end. (2, 0) undoes the most recent append that is still in effect, removing that number. (3, 0) redoes the most recently undone append, putting the number back at the end. Any new append clears the redo history, and an undo or redo with nothing available does nothing. Return the sum over the final sequence of each number times its 1-based position.
Participants numbered 1 to n stand in a circle for an icebreaker. Counting starts at participant 1 and moves around the circle; the participant who is counted k-th leaves, and counting restarts at 1 with the next remaining participant. Return the number of the last remaining participant.
A grading rubric stores an infix scoring formula as integer tokens. Tokens 0 to 100 are numbers; 101 means plus, 102 minus, 103 times, 104 an opening bracket and 105 a closing bracket. Multiplication binds tighter than plus and minus, operators of equal strength apply from left to right, and brackets group as usual. There is no unary minus. Return the value of the formula.
A binary org chart stores a signed contribution score on every node. The root is level 0 and each child sits one level below its parent. Add up the scores on each level and return the largest level total. Scores can be negative, so the answer can be negative too.
Imagine drawing a binary chart on a seating grid: the root takes slot 0 of its row, and a node in slot p places its left child in slot 2p and its right child in slot 2p+1 of the next row. The span of a row is (rightmost occupied slot - leftmost occupied slot + 1), so empty slots between occupied ones still count. Node values do not matter. Return the largest span over all rows.
Two people, a and b, sit somewhere in a binary reporting tree. Their nearest shared manager is the deepest node that has both of them in its subtree; a node counts as part of its own subtree, so if a manages b the answer is a itself, and if a equals b it is that node. Return the depth (edges from the root) of that shared node.
A company hierarchy is given as a parent list, with the founder at node 0. Someone reporting directly to the founder is at depth 1, their reports are at depth 2, and so on. Return how many people sit at exactly depth k. If no one is that deep, return 0.
Call a binary chart evenly staffed when, at EVERY node, the heights of its left and right subtrees differ by at most 1. Height counts nodes on the longest downward path, and an empty subtree has height 0. Print 1 if the chart is evenly staffed, otherwise 0. Checking only the root is not enough.
Badge numbers are stored in a valid strict binary search tree: everything in a left subtree is smaller than the node and everything in a right subtree is larger. Return the k-th smallest badge number, counting from k = 1.
In a binary chart, a left-hand leaf is a node with no children that is attached as the LEFT child of its parent. The root is never a left-hand leaf, even if it stands alone. Return the sum of values of all left-hand leaves, or 0 if there are none.
A downward chain starts at any node of a binary chart and follows child links downward to the same node or one of its descendants, so a single node is a chain on its own. Count the chains whose node values add up to exactly the target. Values may be negative or zero, so chains can overlap and still qualify.
Assessment scores arrive one at a time. After each arrival, if at least k scores have arrived, note the k-th largest score seen so far; repeated scores count as separate entries. Return the sum of all noted values, or 0 if fewer than k scores ever arrive.
A hiring panel shortlists the k highest-scoring candidates. Scores can repeat and can be negative; repeated scores are different candidates. Return the total score of the shortlist.
Several feeds each deliver values in nondecreasing order, and some feeds may be empty. Merge all feeds into one nondecreasing sequence x1, x2, ..., xT and return the checksum 1·x1 + 2·x2 + ... + T·xT. An entirely empty merge has checksum 0.
A single build agent runs jobs one at a time without interruption. Whenever it is idle and at least one job has arrived and is waiting, it starts the waiting job with the shortest duration; ties go to the earlier arrival, then to the smaller job index. If nothing is waiting, it stays idle until the next arrival. A job arriving exactly when the agent frees up is already waiting. Return the sum of all job completion times.
A sensor log holds n readings, possibly repeated. Rank readings by their distance |reading - x| from the calibration point x; among equal distances the smaller reading ranks first. Keep the k best-ranked readings (repeated readings are separate entries) and return their sum.
Response times arrive one by one. After each arrival, take the lower median of everything seen so far: with c values in sorted order, it is the value at zero-based position floor((c-1)/2). Return the sum of these lower medians over all arrivals.
Each learning path is a sequence of skill tokens. A prefix is the first one or more tokens of a path. Return how many DIFFERENT nonempty prefixes appear across all paths; a prefix shared by several paths is counted once.
Each learning path is a sequence of skill tokens. Return the length of the longest token sequence that every path starts with. A path cannot share more tokens than it has, and if the first tokens already disagree the answer is 0.
A course catalogue stores n course codes, each a sequence of tokens; duplicate codes are separate courses. For each of q search queries, count the courses whose code starts with the query tokens (a code equal to the query counts). Return the sum of these counts over all queries.
For each code in a list, find the shortest prefix of it that no OTHER code in the list starts with. When no such prefix exists (the code duplicates another code, or is itself the start of a longer code), use the full code length instead. Return the sum of the chosen lengths over all codes.
Room bookings are closed intervals [start, end] given in any order. Bookings that overlap, or that merely share an endpoint, join into one block, and blocks keep chaining as long as bookings connect. Bookings like [1,2] and [3,4] do not touch, so they stay separate. Return the number of blocks.
A calendar holds closed, already-separated bookings sorted by start, where each booking starts after the previous one ends. A new closed booking [a, b] is added, and it merges with every booking it overlaps or shares an endpoint with, including bookings that only connect after earlier merges. Return the length (end - start) of the merged block that contains the new booking.
Each learner is available on a closed range of integer days [start, end]. A reviewer picks some visit days, and a learner is reviewed if at least one visit day falls inside their range; one visit can serve many learners. Return the fewest visit days that review every learner.
Course modules stand in a row from 0 to n-1. Module i lets you advance to any module from i+1 to i+reach[i]; a reach of 0 means you cannot move forward from it. Starting at module 0, return the fewest moves needed to reach module n-1, or -1 if it cannot be reached. With a single module the answer is 0.
Each learner has a skill level and each practice task has a difficulty. A learner may take a task only when their skill is at least the task difficulty, each learner takes at most one task, and each task goes to at most one learner. Return the largest number of tasks that can be assigned.
Candidates travel to a campus drive in cabs. A cab carries one or two candidates, and their combined luggage weight must not exceed the limit. Every single candidate fits alone. Return the fewest cabs needed for everyone.
An office seating chart stores a team colour code in every cell. Repainting one cell also repaints every cell reachable from it through side-sharing neighbours that carry the same original colour. Return how many cells actually change colour; if the new colour equals the original colour, nothing changes and the answer is 0.
An office map marks staffed desks with 1 and walkways with 0. Desks link only through shared sides. A desk group touching any outer edge of the map has a way out. Count the desk cells that belong to groups with no cell on the outer edge.
At the campus chess club a knight jumps two squares in one direction and then one square sideways. On a board of rows × cols squares, return the fewest jumps that take the knight from its start square to the target square without leaving the board. Return 0 when start and target coincide and -1 when the target can never be reached.
Desks in an office grid hold 0 for an empty desk, 1 for a laptop still waiting for a security patch and 2 for a laptop that already has it. Every minute, each patched laptop passes the patch to waiting laptops directly above, below, left or right of it, all at the same time. Return the number of minutes until no laptop is waiting, 0 if none waits at the start, or -1 if some waiting laptop can never receive the patch.
A learning plan is a directed graph in which every edge u→v satisfies u < v, so it never loops back. Count the distinct directed routes from milestone 0 to milestone n-1, modulo 1,000,000,007. Parallel edges between the same milestones form different routes. When n = 1 the empty route counts once.
A course catalogue has n modules and m prerequisite pairs (a,b) meaning module a must be finished before module b can begin. A module becomes finishable once every one of its prerequisites is finished. Return how many modules can eventually be finished. Modules inside a circular chain, or depending on one, never become finishable; a pair (a,a) blocks module a.
A floor plan marks open floor with 0 and furniture with 1. From an open cell you may step to any of the eight surrounding cells, diagonals included, as long as it is open. Return the fewest steps from the top-left cell to the bottom-right cell. Return 0 if they are the same open cell and -1 if either corner is furniture or no route exists.
Cables between n rooms are installed one at a time in the listed order. Return the 1-based position of the first cable whose two ends were already linked through earlier cables; a cable from a room to itself is always redundant. Return 0 if every cable links two previously separate groups.
An announcement starts at server s and travels along one-way links; a link (u,v,t) delivers it from u to v t milliseconds after u has it. Servers forward immediately. Return the moment the last server first receives the announcement, which is the largest of the shortest delivery times. Return -1 if some server never receives it; a lone server gives 0.
A team offsite hiking map stores an altitude for each cell. A trail runs from the top-left cell to the bottom-right cell through side-adjacent cells. Its effort is the largest absolute altitude change between two consecutive cells along it, and a single-cell trail has effort 0. Return the smallest effort any trail can achieve.
A fitness challenge on the office staircase lets you climb 1, 2 or 3 steps per move. Count the distinct ordered move sequences that finish exactly on step n, modulo 1,000,000,007. For n = 0 the empty sequence counts once.
A certification ladder has n rungs numbered 0 to n-1, each with a fee. You may begin on rung 0 or rung 1 for free. Each move goes up one or two rungs, and you pay the fee of the rung you leave. Return the minimum total fee needed to reach position n, just above the last rung.
A career fair has n booths in a row, each with a non-negative sponsorship value. Volunteers may staff any booths except two that stand next to each other. Return the largest total value of a valid selection; selecting no booth gives 0.
n mentors sit around a round table, each with a non-negative rating. Invite mentors so that no two invited mentors sit side by side; seat n-1 sits beside seat 0. A lone mentor (n = 1) may be invited. Return the largest total rating of the invited mentors.
Each optional course has a cost and a skill value. Pick courses, each at most once, whose total cost stays within the training budget. Return the greatest total skill value. Courses that cost 0 always fit.
A lead must hand every one of n tasks, each with a positive effort, to exactly one of two squads. Print 1 if the squads can end up with equal total effort, otherwise 0.
Count the sets of expense positions whose amounts add up exactly to the target. Two selections differ if they use different positions, even when the amounts match. The empty selection counts when the target is 0.
An intern stipend of exactly total rupees is paid using notes of the given distinct denominations, with unlimited notes of each kind. Count the different collections of notes that pay it; the order in which notes are handed over does not matter. Return the count modulo 1,000,000,007. A total of 0 is paid in one way, with no notes.
A skill log is a sequence of integer codes. Return the length of the longest subsequence that reads the same from both ends. A subsequence keeps the original order but may skip codes.
Sprint checkpoints are numbered 0 to n-1. From checkpoint i you may leap forward to any checkpoint from i+1 up to i+reach[i]. Return the fewest leaps needed to get from checkpoint 0 to checkpoint n-1, 0 when n = 1, or -1 if the last checkpoint cannot be reached.
Positive bonus tokens stand in a row. Removing a token earns left × value × right, where left and right are the values of its nearest tokens still standing on each side, and a missing side counts as 1. Remove every token in any order you like and return the largest total earnings.
Report piles stand in a row with given page counts. One step merges two NEIGHBOURING piles into a single pile in their place and costs the combined page count. Keep merging until one pile remains and return the minimum total cost. Because only neighbours may merge, the two smallest piles are not always available together.
Every cell of a skill map holds a level. A trail moves between side-adjacent cells, and each step must go to a STRICTLY higher level. Return the number of cells on the longest possible trail; any single cell is a trail of length 1.
A service is stable up to some unknown load level L between 0 and n, and level 0 is always safe. Testing at level x crashes the test server exactly when x > L; a crashed server is lost, while a surviving one can test again. With k identical test servers, return the minimum number of tests that is guaranteed to pin down L in the worst case.
Design a service that reminds learners about scheduled practice. Support email and push, local time zones, opt-outs and delivery history.
Design a community library where learners voluntarily publish code/design artifacts and reviewers leave structured feedback. Private drafts must stay private.
Design a code execution service for timed assessments. Keep hidden tests private and isolate arbitrary submissions from application credentials and other tenants.
Limit API usage across free and paid tenants while retaining clear retry behavior.
Create short public links with expiration, click analytics and abuse controls.
Support one-to-one chat, offline delivery and per-conversation ordering.
Build a feed of followed creators with private-account permissions and muted topics.
Search products by text, category and price while preserving stock freshness.
Sell limited seats with temporary holds, payments and cancellation.
Consume provider payment events and maintain an auditable order payment state.
Coordinate checkout, inventory, payment and fulfillment across independent services.
Upload large work artifacts with interruption recovery, access control and scanning.
Cache frequently read profile summaries while supporting owner updates and deletion.
Manage browser/device sessions, logout-all and account risk actions.
Collect application logs for tenant-scoped debugging and retention.
Collect service metrics and notify operators when rules breach thresholds.
Serve flags to clients with staged rollouts and rollback.
Match riders with nearby available drivers and confirm one assignment.
Support shared document editing, offline reconnect and version history.
Book interviewer time slots while respecting availability and cancellations.
Ingest public authorized job feeds, normalize records and expose original source provenance.
Store editable resume versions and owner-controlled export/share snapshots.
Suggest the next practice task from recorded mistakes and explicit goals.
Reserve product quantities during checkout across warehouses.
Ingest parcel scans and display a coherent tracking history to customers.
Upload videos and produce multiple playback renditions with status tracking.
Store private photos, generate thumbnails and support shared albums.
Notify when a device enters or leaves a configured geographic zone.
Roll out signed device updates with staged cohorts and rollback.
Rank participants by score and show neighborhood rankings with tie rules.
Route requests to services with per-route authentication, timeouts and canary versions.
Coordinate workers so a task has one valid lease holder at a time.
Run tenant tasks at scheduled times with retries and missed-run policies.
Transform events into curated analytics records with schema evolution.
Provide customer dashboards over tenant-scoped event aggregates.
Assign users to experiments and record exposure events consistently.
Let users export their own data as a bounded downloadable archive.
Keep account reads/writes available across two regions with a defined recovery policy.
Migrate a large user table to a new schema while the application keeps writing.
Deliver credentials to authorized services with rotation and audit history.
Reserve budgets before paid operations and reconcile actual costs afterward.
Sync learner notes between phone and browser with offline edits and deletion.
Collect transaction risk signals and queue cases for authorized human review.
Answer preparation questions using an approved content library with source references.
Publish coding questions while keeping grading cases private and preserving old submissions.
Allocate isolated code-runner workers across competing tenants with deadlines.
Meter API consumption and produce monthly tenant invoices from usage events.
Crawl an explicitly authorized set of public domains with duplicate detection and resource budgets.
Verify account email with expiring one-time links, resend limits and delivery status.
Route incoming support cases to qualified agents while preserving case history.