Practice Minimum Number of People to Teach
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
There are n languages and m users. languages gives the languages each user knows, and each pair in friendships identifies two direct friends. Two friends can communicate when they share at least one language. Choose a single language and teach it to as few users as possible so that every listed friendship can communicate. Friendships are not transitive: only the supplied pairs impose a requirement. Return the smallest number of users taught.
Source: Minimum Number of People to Teach on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 2, languages = [[1],[2],[1,2]], friendships = [[1,2],[1,3],[2,3]]
1
# Example 2
n = 3, languages = [[2],[1,3],[1,2],[3]], friendships = [[1,4],[1,2],[3,4],[2,3]]
2
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Number of People to Teach.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.