Satisfiability of Equality Equations Problem
Satisfiability of Equality Equations Problem — ExecCode Medium DSA Practice
Solve the Satisfiability of Equality Equations problem on ExecCode. Free online medium DSA practice in DSU. Write and run code in Java, C++, Python — no signup required to run.
Problem description
You are given an array of strings equations that represent relationships between single lowercase-letter variables. Each string has length 4 and is either "xi==yi" or "xi!=yi". Return true if it is possible to assign integer values to every variable so that all the given equations hold simultaneously, and false otherwise.
Examples
Input equations = ["a==b", "b!=a"]; Output false. Input equations = ["b==a", "a==b"]; Output true. Input equations = ["a==b", "b==c", "a!=c"]; Output false
Constraints
1 ≤ equations.length ≤ 500 equations[i].length == 4 equations[i][0], equations[i][3] are lowercase letters. equations[i][1] is either "=" or "!". equations[i][2] is "=".
Practice Satisfiability of Equality Equations free on ExecCode. Browse DSA problems, topic map, and placement guides.