Find the best tower that can be reached under the problem’s movement or reachability rules.
Problem
You are given a set of towers and the rules for moving or reaching from one tower to another. Determine which tower is the best reachable tower according to the problem’s scoring or selection rule.
In general, you should:
- determine which towers are reachable from a starting tower or set of towers,
- evaluate the reachable candidates using the provided criterion,
- return the tower that is considered best.
If multiple towers satisfy the rule, choose the one specified by the tie-breaking condition in the problem.
Goal
Compute the best tower that can be reached while respecting the allowed transitions between towers.
Input Format
- The first line or first field describes the number of towers.
- The next data describes tower properties and the allowed reachability relations.
- A starting tower or starting set may be provided.
The exact input structure depends on the platform’s format, but the core data is a graph or connectivity model over towers.
Output Format
Return the identifier, index, or value of the best reachable tower as required by the statement.
Constraints
- Tower count is assumed to be within a range suitable for graph traversal.
- Reachability relations may be directed or undirected depending on the instance.
- The solution should be efficient enough for linear or near-linear traversal over the towers and connections.
Example 1
Input
n = 5 values = [3, 7, 2, 9, 5] edges = [[0,1],[1,2],[1,3],[3,4]] start = 0
Output
3
Explanation
From tower 0, all towers are reachable through the connections. If the best reachable tower is the one with the highest value, tower 3 is selected because it has value 9.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.