Search
⌘K

Leetcode 990. Satisfiability of Equality Equations

Determine if a set of equations like "a==b" and "a!=b" over single-letter variables is satisfiable by grouping variables connected by equalities (e.g., with union-find) and checking that no inequality relates variables in the same group. There are at most 26 lowercase variables and up to 500 equations.

Asked at:

Amazon

Amazon


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Mid August, 2025

Amazon

Amazon

Junior

You are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one of two different forms: "xi==yi" or "xi!=yi".Here, xi and yi are lowercase letters (not necessarily different) that represent one-letter variable names. Return true if it is possible to assign integers to variable names so as to satisfy all the given equations, or false otherwise.

Comments

Your account is free and you can post anonymously if you choose.