2-SAT satisfiability

Write codeHard40 minCitadel style

Your task

You are wiring up a feature-flag system. There are n boolean variables (numbered 1..n) and a list of 2-clauses; each clause is a pair [a, b] of literals meaning (a OR b) must hold, where a positive integer i means variable i is true and -i means variable i is false. Determine whether some assignment of all n variables satisfies every clause. Constraints: 1 <= n <= 5000, clauses may be empty, and a literal pair may repeat or be a tautology like [i, -i].

Examples

two_sat_satisfiable(n: int, clauses: list[list[int]]) -> bool
Example 1
Inputtwo_sat_satisfiable(3, [[1, 2], [-2, 3], [-1, -3], [3, 2]])
OutputTrue