Calculate Visited Countries
Problem Overview
- Given a bidirectional flight network of n countries forming a tree, each marked Open or Restricted.
- For each country as a start, find the maximum countries visitable when Restricted can be converted to Open only in pairs, not exceeding the number of Restricted; sum these maxima across all starts.
- Input: n (<=50005), edges, and status of each country; Output: the total sum.
- Real-world Covid flight rules context with permission constraints.
- Uber interviews: a coding interview problem and interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
