Graph Theory37 sections · 1633 units
Open in Course

LeetCode 990 Satisfiability of Equality Equations - Problem Statement

LeetCode 990

Problem: Satisfiability of Equality Equations Task: Given equations like "a==b" and "a!=c", determine if they can all be satisfied. Process all "==" equations first (union the variables). Then check "!=" equations. If any "!=" connects variables in the same group, return false.

This two-pass approach works because equality is transitive. If a==ba == b and b==cb == c, then a==ca == c. After unioning all equalities, any inequality between members of the same component is a contradiction.