You are given three independent coding tasks.
You have:
recipes
: a list of
n
item names.
ingredients[i]
: a list of names required to produce
recipes[i]
.
supplies
: a list of names you already have available in unlimited quantity.
Any ingredient name may refer either to a basic supply or to another recipe. You may produce a recipe only if all of its required ingredients are currently available (either from the initial supplies or from recipes you have already produced).
Task: Return all recipes that can eventually be produced.
Notes/constraints:
n
can be large; assume the total number of ingredient references across all recipes can be up to ~2e5.
You are given a directed graph with positive edge weights:
n
nodes labeled
1..n
edges
: a list of triples
(u, v, w)
meaning an edge from
u
to
v
with travel time
w > 0
k
A signal starts at node k at time 0 and travels along directed edges, accumulating time.
Task: Compute the time when all nodes have received the signal (i.e., the maximum of the shortest-path times from k to every node). If some node is unreachable, return -1.
Notes/constraints:
n
up to ~1e5,
|edges|
up to ~2e5.
You are given the head of a singly linked list.
Task: Determine whether the list length is odd or even using O(1) extra space and without explicitly computing the length with a counter.
Output: Return something like "odd" / "even" (or a boolean), as long as the meaning is clear.
Notes/constraints:
0
).