Daily challenge for 2026-10-24
662. Minimum Network Hubs Placement
Given a tree of n nodes labeled from 0 to n - 1 specified by a list of undirected edges, find the minimum number of hubs needed such that every node either contains a hub or is adjacent to a node containing a hub (Minimum Vertex Dominating Set on a tree).
Constraints:
The input is a valid simple connected undirected tree with 1–500 nodes and exactly n-1 edges. Every endpoint is an integer from 0 to n-1. A hub covers its own node and all directly adjacent nodes.
Example:
Input: n = 4, edges = [[0, 1], [1, 2], [1, 3]]
Output: 1
Run this challenge interactively in Python or JavaScript when the app loads.