An A/B test needs to put each of n testers, numbered 0 to n - 1, into group A or group B. Some pairs of testers share a household, and the pairs in conflicts must end up in different groups so they don't compare notes.
Write canSplit(n, conflicts) that returns true if every tester can be put in a group so that no conflicting pair is in the same group, and false otherwise.
Input: n = 4, conflicts = [[0,1],[1,2],[2,3],[3,0]] Output: true
Put 0 and 2 in group A and 1 and 3 in group B.
Input: n = 3, conflicts = [[0,1],[1,2],[2,0]] Output: false
In a triangle, two of the three testers must share a group.
1 <= n <= 100000 <= conflicts.length <= 500000 <= a, b < n, a !== bRun tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #451 Split Testers Into Two Groups. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.