Determine whether every level in a game can be passed using the combined set of levels completed by two players.
Problem 469A
gfgProblem
A game has levels numbered from $1n$.
Two players each know a list of levels they can complete. If we combine the levels known by both players, can we cover every level from $1n$?
Return YES if every level appears in at least one of the two lists, otherwise return NO.
Goal
Check whether the union of the two players' level sets contains all levels from $1n$.
Input Format
- The first line contains an integer .
- The second line contains an integer followed by distinct level numbers known by the first player.
- The third line contains an integer followed by distinct level numbers known by the second player.
Output Format
- Print
YESif every level from $1n$ is covered by at least one player. - Otherwise print
NO.
Constraints
- (typical for this problem)
- Level numbers are in the range $1..n$
- The listed levels for each player are distinct
Example 1
Input
4 3 1 2 3 2 2 4
Output
YES
Explanation
The combined levels are {1,2,3,4}, so every level is covered.
Example 2
Input
4 3 1 2 3 2 2 3
Output
NO
Explanation
Level 4 is missing from both lists, so not all levels are covered.
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.