1var equationsPossible = function (equations) {2const A = "a".charCodeAt(0);3const n = equations.length;4const parent = new Array(26).fill(0).map((_, i) => i++);56const find = (x) => {7if (parent[x] === x) {8return x;9} else {10return (parent[x] = find(parent[x]));11}12};1314for (const eq of equations) {15if (eq.charAt(1) === "=") {16parent[find(eq.charCodeAt(0) - A)] = find(eq.charCodeAt(3) - A);17}18}1920for (const eq of equations) {21if (22eq.charAt(1) === "!" &&23find(eq.charCodeAt(0) - A) === find(eq.charCodeAt(3) - A)24) {25return false;26}27}2829return true;30};