Question 11

Given a set of N numbers [1,N], partition them into 2 disjoint subsets based on a set of K queries.

Each query is of the type (n1, n2) where n1 and n2 are distinct numbers from the set and n1 and n2

belong to opposite subsets.

Example:

Input:

Input:

N = 4

K = [(1, 2), (1, 3), (2, 4)]

Output:

Set 1 : (1,4)

Set 2 : (2,3)

[advanced_iframe securitykey=”undefined” src=”https://code.kodnest.com/” width=”100%” height=”600″]

×