Find the final signal arrival
A directed network has nonnegative travel times. Return the time when every node first receives a signal from source, or -1 when a node is unreachable.
Original personal curriculum
Every row is an original coding question. These are review-gated candidates, not copied third-party questions. The catalog contains 250 candidates before publication.
A directed network has nonnegative travel times. Return the time when every node first receives a signal from source, or -1 when a node is unreachable.
Return the smallest total cost needed to connect every station with undirected links. Return -1 when full connection is impossible.
Return the least travel cost from source to destination using at most maxHops edges. Return -1 when no such route exists.
Return the minimum total wire length that connects every station. Each edge gives two station IDs and a positive cost.
Return shortest distances from source in a directed graph with negative edges. Return null when a reachable negative cycle exists.
Return the lowest price from start to goal using at most maxStops intermediate stops. Return -1 when no allowed route exists.
Return every undirected edge whose removal increases the number of connected components.
Return the highest success probability from start to goal when edge probabilities multiply.
Process merge and connected queries. Return answers for connected queries in order.
Return the least route cost with at most maxStops intermediate nodes.
Return the time until all nodes receive a signal, or -1 when any node stays unreachable.
Return a map that gives the count for each integer in values.
Return the first index whose value occurred at an earlier index. Return -1 when no value repeats.
Return each integer that occurs in both input lists exactly once. Keep the order from the first list.
Return the longest contiguous span whose integer values sum to zero.
Return the number of index pairs whose values have a sum divisible by divisor.
Each request adds delta to every value from left through right. Return the final value list after all requests.
Return the first value from left that also occurs in right. Return null when the lists share no value.
Return the number of split positions where the sum before the split equals the sum after it.
Return values with even values first and odd values second. Preserve the original order inside each group.
Return the smallest positive integer missing from values. Use the input array as storage when possible.
Return the smallest nonnegative integer that does not occur in values.
Return an array where each output position is the product of all input values except that position. Do not use division.
Return the smallest positive integer that does not occur in values.
Return the total water trapped between nonnegative column heights after rain.
Return true when a list contains equal counts of positive and negative values. Ignore zero.
Remove duplicates from a sorted array in place and return the new length.
Return the longest contiguous span with equal even and odd values.
Return values where each position equals the product of all other values without division.
Return the smallest positive integer that does not occur in values.
Return the count of contiguous spans whose values sum to target.
Return all unique combinations of distinct input values that total target. Use each input position at most once.
Return true when adjacent grid cells can spell word. Moves use up, down, left, or right. Do not reuse a cell in one route.
Return the largest sum from a list when selected positions cannot be adjacent. Also return one valid set of selected positions.
Return all strings with count opening and count closing parentheses that are balanced at every prefix.
Return every size-count combination of values from 1 through limit in ascending lexical order.
Return the number of routes from start to finish in an open grid. Move up, down, left, or right and visit each cell at most once per route.
Insert three dots into digits to create all valid four-part addresses. Each part is 0 through 255 and has no leading zero unless it is zero.
Return all combinations of distinct positive input values that sum to target. Return each combination in ascending value order.
Assign plus or minus before each value. Return the number of assignments with total target.
Return all value selections whose sum equals target and whose selected indices are not adjacent.
Return valid four-part addresses from a digits-only string.
Return all letter strings that a digit string can form with a phone keypad.
A boolean array is false before one boundary and true from that boundary onward. Return the first true index, or -1 when none exists.
Return the greatest nonnegative integer whose square is not greater than value.
Each job has a positive integer size. A worker processes at most rate units from one job per hour. Return the smallest rate that completes every job within hours.
Return the last index containing a negative number in a sorted integer list. Return -1 when no value is negative.
An ascending list of distinct integers was rotated. Return its smallest value in logarithmic time.
Packages must ship in order over days days. Return the smallest daily capacity that ships every package on time.
Return the first index whose sorted value is greater than target. Return values.length when none exists.
A value is a peak when it is greater than its existing neighbors. Return any peak index.
Return an index whose value is not smaller than adjacent values. Values outside the list act as negative infinity.
Return the index of target in a rotated ascending list of distinct integers. Return -1 when absent.
Return an index whose value is greater than its immediate neighbors. Values outside the list act as negative infinity.
Return the smallest index where a false-then-true predicate becomes true. Return -1 when none is true.
Return the row index with the fewest leading zeroes in a sorted binary matrix.
Return the smallest value in a rotated sorted array with distinct values.
Return the kth positive integer absent from a sorted positive list.
Return the number of one bits in a nonnegative integer.
Every transmission ID appears twice except one. Return the ID that appears once.
Permissions are bit masks. Return true when every bit in required also appears in granted.
Return true when value is a positive power of two.
Reverse the lowest width bits of value. Return the resulting nonnegative integer.
Every integer appears exactly three times except one. Return the integer that appears once.
Return the XOR of every integer from start through end, inclusive.
Reverse the low width bits of a nonnegative integer and return the result.
Return the zero-based position of the least significant one bit. Return -1 for zero.
Return the bitwise XOR of all integers from left through right.
Return the number of one bits for every value from zero through limit.
A trail has a fatigue cost at each marker. Start before marker 0. Move one or two markers per step. Return the least total cost to reach beyond the last marker.
A signal is a string of digits. A one-digit group from 1 through 9 is valid. A two-digit group from 10 through 26 is valid. Return the number of valid full splits.
Each message has a value. You cannot choose adjacent messages because they use the same channel. Return the largest total value.
Sensors form a circle. Activating adjacent sensors causes interference. Return the largest total reading from nonadjacent sensors.
A marker may advance one or three positions at a time. Return the number of ordered ways to reach exactly distance.
Return the length of the longest strictly increasing subsequence in readings.
Choose a nonempty subsequence. Add the first chosen value, subtract the next, then continue alternating signs. Return the greatest possible total.
Return the largest total from values when selected indices must differ by at least two.
Return true when text can split into dictionary words without unused characters.
Choosing value x earns its total occurrences but prevents choosing x minus one and x plus one. Return the greatest score.
Return how many ways text can split into dictionary words. Return zero when no full split exists.
Return the number of ways to reach step n using moves of one, two, or a rest move of zero once per path.
Return the number of letter decodings for a digits string where 1 maps to A through 26 maps to Z.
Return the greatest sum from values when adjacent positions cannot both be selected.
A robot starts at the upper-left cell and moves only right or down. Cells with -1 are blocked. Return the number of routes to the lower-right cell.
Move from the upper-left cell to the lower-right cell using only right and down moves. Return the smallest sum of visited risk values.
Two route codes are strings. Return the length of their longest shared sequence. Characters must keep their relative order.
Return the smallest number of insertions, removals, and replacements needed to change source into target.
A grid contains zero for clear cells and one for blocked cells. Return the side length of its largest all-clear square.
Return true when target can be formed by interleaving left and right while keeping the order within each source.
Rows contain paint costs for three colors. Paint one color per row. Adjacent rows cannot use the same color. Return the least total cost.
Start in any top-row cell. Move to the next row directly below, below-left, or below-right. Return the smallest total.
Return the minimum top-to-bottom total in a number triangle.
Return the greatest total collected by two travelers moving down or right through a grid.
Return the fewest insertions, deletions, and replacements needed to convert first into second.
Return the number of square submatrices containing only one values.
Return the size of each connected component in an undirected graph. Return component sizes in ascending order.
Return true when a directed graph has a route from start to destination.
Return a valid task order from prerequisite pairs. Return an empty list when the dependencies contain a cycle.
Return all directed-graph nodes from which every possible route eventually reaches a node with no outgoing edge.
Given an undirected graph with nodes zero through nodeCount minus one, return its number of connected components.
Return the smallest number of words in a one-letter-change route from start to goal using only allowed words. Return zero when no route exists.
Return one order that completes every task after its prerequisites. Return an empty list when the prerequisites contain a cycle.
Return true when an undirected graph can assign one of two colors to every node without equal-colored neighbors.
Return the earliest time to reach the lower-right cell. At time t, you may enter only cells with height at most t.
Return true when a directed route exists from start to goal.
Return a deep copy of a connected undirected graph node.
Return the number of shortest paths from start to goal in an unweighted undirected graph.
Change every zero region fully surrounded by ones into ones. Keep zero regions connected to the border.
Return the shortest unweighted path length from start to goal that uses requiredEdge in either direction. Return -1 when none exists.
Return the shortest edge count from start to goal using an even number of edges. Return -1 when none exists.
Return true when graph nodes can use two colors with different edge endpoints.
Return one valid task order from prerequisite pairs. Return an empty list for a cycle.
Return the fewest one-letter changes from start to goal using only dictionary words.
A vehicle starts with zero fuel. Each checkpoint provides fuel and is at a known distance. Return the smallest number of refuels needed to reach destination, or -1.
Each project takes one day, has a deadline, and has a reward. Return the largest reward from projects completed by their deadlines.
Remove exactly k digits from a nonnegative decimal string. Return the smallest possible remaining number without leading zeros.
Each value gives the farthest forward jump from its index. Return true when the last index is reachable.
Each person is [height, ahead], where ahead is the number of people at least that tall before them. Return one valid queue.
Locations form a circle. Supply[i] is collected at location i and cost[i] is needed to reach the next location. Return a valid start index or -1.
Each value gives the greatest forward jump from its index. Return the fewest jumps needed to reach the last index.
Each child needs at least one reward. A child with a greater rating than a neighbor needs more rewards. Return the smallest total.
Split a lowercase string into the largest number of parts where no letter appears in more than one part.
Return the fewest refuel stops needed to reach target. Return -1 when impossible.
Return the fewest points needed to intersect every closed interval.
Split text into the most parts so each symbol occurs in only one part.
Return true when jumps of at most each value can reach the final index.
Return request identifiers in service order. Lower priority numbers run first. Equal priority requests keep their arrival order.
Merge several individually sorted event-time lists into one sorted list of event times.
For each prefix of integer values, return its median. For an even prefix, return the lower middle value.
Return the kth smallest nonnegative distance in an unsorted list.
Merge ascending reading lists into one ascending list.
Return the k integer values with the greatest occurrence counts. For equal counts, return the smaller value first.
Rearrange symbols so equal symbols are never adjacent. Return an empty string when this is impossible.
Given ascending integer lists, return the shortest inclusive range containing one value from every list.
Return k points nearest the origin. Break equal distances by x then y.
Return one sorted list from sorted integer lists.
Reorder text so equal adjacent symbols never occur. Return an empty string when impossible.
Given time ranges with inclusive starts and ends, merge overlapping or touching ranges. Return ranges in ascending start order.
Each delivery uses a gate from start through end, with an end freeing the gate before a new start at the same time. Return the smallest required gate count.
Return the largest number of nonoverlapping sessions. A session ending at time t is compatible with one starting at t.
Given closed coverage ranges and a limit, return the first integer from zero through limit that no range covers. Return -1 when all are covered.
Each event has an inclusive start and end day. Attend at most one event per day. Return the greatest number of events you can attend.
Return the fewest ranges to remove so all remaining half-open ranges do not overlap.
Return the fewest rooms for half-open meetings. A meeting ending at time t frees a room for one starting at t.
Return the combined length covered by closed integer intervals.
Return finite gaps not covered by any employee interval.
Insert a closed interval into sorted disjoint ranges and merge overlaps.
Return the fewest rooms required for half-open meeting intervals.
Reverse a singly linked chain and return its new first node.
Merge two ascending singly linked chains and return one ascending chain.
Return the middle node of a singly linked chain. For an even number of nodes, return the second middle node.
Remove the kth node from the end of a singly linked chain and return the resulting head.
Reorder a singly linked chain so nodes below pivot appear before nodes at or above pivot. Preserve the order within each group.
Return the node where a singly linked chain cycle begins. Return null when the chain has no cycle.
A singly linked chain is sorted in ascending order. Remove duplicate nodes so every value occurs once.
Each node has next and random links. Return an independent deep copy with matching links.
Two linked chains store nonnegative integers with least-significant digits first. Return their sum in the same form.
Remove every second node from a singly linked chain, starting with the second node. Return the original head.
Two singly linked chains may share a tail. Return the first shared node, or null when they do not intersect.
Swap each adjacent pair of nodes in a singly linked chain. Leave a final unpaired node unchanged.
Given a sorted linked chain, remove repeated values so each value occurs once.
Return the number of shared node references at the end of two linked chains.
Reverse nodes from position start through end, using one-based positions.
Reorder nodes as first, last, second, second-last, and continue inward.
Create a deep copy of a linked chain whose nodes also have random references.
A rectangle has axis-aligned corners. Return its area from two opposite corners. Coordinates may be negative.
Return a stable direction key for a vector dx, dy. Equal directions must return equal keys even when both values have a common factor.
Positive integers fill an outward square spiral. Return the value at row and column, where the center is 1 at 0,0.
Return the smaller angle between an analog clock hour hand and minute hand.
Return true when two axis-aligned rectangles share an area with positive width and height. Edge-only contact is false.
Repeatedly replace a positive integer with the sum of its squared decimal digits. Return true when the process reaches one. Return false when it repeats another value.
Return the number of shortest paths from 0,0 to right,up when each move increases exactly one coordinate by one.
Return the area shared by two axis-aligned rectangles. Return zero when they do not overlap.
Return the smaller angle between hour and minute hands.
Return the greatest number of points on one straight line.
Return grid coordinates visited in clockwise spiral order from the upper-left cell.
Return true when moves U, D, L, and R return a robot to the origin.
Return the greatest sum of any contiguous window with exactly width values.
Return the greatest length of a substring with no repeated character.
Return the shortest substring of text that contains every character in required with at least its required count. Return an empty string when absent.
Return the greatest average of any contiguous window with exactly width values.
Return the greatest substring length that can contain one repeated character after changing at most changes symbols.
Values are positive integers. Return the smallest contiguous length whose sum is at least target. Return zero when no window reaches target.
Return true when text contains a contiguous permutation of pattern.
Return the largest sum of a contiguous positive-integer subarray whose sum is at most limit.
Return the longest substring that contains at most limit distinct characters.
Return the first index where text contains a permutation of pattern. Return -1 when no such substring exists.
Return the greatest length of a positive-integer subarray with sum at most limit.
Return the longest substring with at most limit vowels.
Return the number of subarrays with at least k distinct values.
Return every start index where text contains a rearrangement of pattern.
Return the shortest text span that contains every required symbol with its required count.
Return true when every opening delimiter has the correct later closing delimiter. Support parentheses, brackets, and braces.
For each integer, return the first later integer that is greater. Use -1 when no later greater value exists.
Evaluate tokens containing integers and the operators +, -, *, and /. Division truncates toward zero.
Return a string after removing the fewest parentheses needed to make nesting valid. Keep all non-parenthesis characters.
For each temperature, return how many later days pass before a warmer temperature occurs. Return zero when none occurs.
Bar heights form a histogram. Return the largest rectangle area that uses consecutive bars.
Process push and pop operations. Return the minimum after each operation, or null when the stack is empty.
Positive and negative values move right and left. Return values that remain after equal-speed collisions.
Normalize an absolute path with slash separators, dot for the current directory, and dot-dot for the parent directory.
For each value, return the number of positions to the first later smaller value. Return -1 when no such value exists.
For each temperature, return how many later positions lead to a warmer temperature. Return zero when none exists.
Repeatedly remove adjacent equal characters. Return the remaining string.
Return the score where [] is one and nesting doubles a score.
Return how many later positions each temperature waits for a warmer value.
Return the largest rectangle area under a histogram of nonnegative heights.
Return the largest number of non-null nodes that occur at one depth in a binary tree.
Return the sum of values in a binary search tree that are within an inclusive lower and upper bound.
Return the last node value at each depth when a binary tree is scanned from left to right.
Return true when a binary tree has a downward parent-to-child path whose values total target. A path may start at any node.
Return the smallest number of nodes on a root-to-leaf path. Return zero for an empty tree.
Return true when every node in a binary tree satisfies strict binary-search-tree ordering.
Return the largest sum on a root-to-leaf path in a binary tree. Node values can be negative.
Return the lowest common ancestor of two values only when both values occur in a binary tree. Return null otherwise.
Return the average node value for every level of a binary tree.
Return the largest number of non-null nodes at one depth in a binary tree.
Return the leftmost value on the deepest level of a nonempty binary tree.
Encode a binary tree as text and rebuild the same tree from that text. Preserve null children.
Return the last visible node value at every depth when a binary tree is viewed from the right.
Return the sum of values that are leaf nodes reached through a left edge.
Return the lowest common ancestor of two values in a binary tree with unique values.
Return node count in a complete binary tree faster than a full traversal when possible.
Return tree values grouped from leftmost vertical column to rightmost.
Return the visible node value from the right side at each tree depth.
Build the unique binary tree defined by preorder and inorder traversals.
Build a prefix registry from lowercase words. Return how many stored words begin with each query prefix.
Return true when a word registry contains a word matching a pattern. The question mark matches exactly one lowercase letter.
Given root words and a sentence, replace each sentence word with its shortest matching root. Keep unmatched words.
Return up to limit stored words that begin with prefix, ordered by increasing word length and then alphabetically.
Return how many distinct stored lowercase words begin with prefix.
Return true when each row of same-length words equals the matching column.
Return the shortest prefix of word that occurs in no other dictionary word. Return an empty string when none exists.
For every word, return the sum of dictionary prefix occurrence counts.
Return true when text can split into one or more dictionary words.
Given ascending values and a target, return two distinct indices whose values add to the target. Return an empty list when absent.
Modify a sorted integer list so its first k positions contain each distinct value once. Return k.
Two vertical markers have nonnegative heights. Return the largest area formed by two markers and the positions between them.
Return true when three distinct positions in values sum to target. Return false when no such three positions exist.
Return a copy of text with vowels reversed while every other character stays in place.
Return the sum of three distinct values whose total is closest to target. Inputs always have one unique closest total.
Return true when text can become a palindrome after removing at most one character.
Return the total water held between nonnegative bar heights after rain.
Return true when letters and digits in text read the same forward and backward. Ignore case and other characters.
Reorder values that contain only 0, 1, and 2 so equal values are adjacent in ascending order.
Sort values containing only 0, 1, and 2 in place.
Given sorted values, return whether two distinct values have squared values that sum to target.
Reverse the word order in a mutable character array.
Return the greatest area between two vertical heights.
Sort values containing only zero, one, and two without a general sort.
Complete the skills check before you select a weekly plan. The plan should prioritize concepts with weaker answered evidence.