var equationsPossible = function(equations) { let parent = newArray(26); for (let i = 0; i < parent.length; i++) { parent[i] = i; } const a = 'a'.charCodeAt(); for (const e of equations) { if (e[1] === '=') { union(parent, e[0].charCodeAt() - a, e[3].charCodeAt() - a); } } for (const e of equations) { if (e[1] === '!') { if ( find(parent, e[0].charCodeAt() - a) === find(parent, e[3].charCodeAt() - a) ) returnfalse; } } returntrue; }; functionunion(parent, a, b) { parent[find(parent, a)] = find(parent, b); } functionfind(parent, i) { while (parent[i] !== i) { parent[i] = parent[parent[i]]; i = parent[i]; } return i; };