var equationsPossible = function (equations) {
const Obj = {};
for (let i = 97, j = 1; i < 124; ++i){
const char = String.fromCharCode(i);
Obj[char] = j++;
}
equations.forEach(ele => {
if (ele[1] === '=') {
if (Obj[ele[0]] != Obj[ele[3]]) {
const a = Obj[ele[0]]
const b = Obj[ele[3]]
for (const key in Obj) {
if (Obj[key] === a) {
Obj[key] = b;
}
}
}
}
});
console.log(Obj);
for (let i = 0; i < equations.length; ++i){
if (equations[i][1] === '!') {
if (Obj[equations[i][0]] === Obj[equations[i][3]]) {
return false;
}
}
}
return true;
};