2
* @param {number[]} row5
var minSwapsCouples = function (row) {6
let currentPositions = [];8
for (let i = 0; i < row.length; i++) {9
currentPositions[row[i]] = i;17
j += 2 // Looping through the couches19
let leftPartner = row[j];20
let correctRightPartner = getPartner(leftPartner);21
if (row[j + 1] !== correctRightPartner) {22
console.log("unhappy");23
//Swap Positions of positions - Bring the Correct Right Partner in the Couch24
let tempValue = row[j + 1];25
row[j + 1] = correctRightPartner;26
let tempPosition = currentPositions[correctRightPartner];27
row[tempPosition] = tempValue;29
//Correct the Hash Table keeping the currentPositions of each Person.30
currentPositions[correctRightPartner] = j + 1;31
currentPositions[tempValue] = tempPosition;39
console.log("currentPositions", currentPositions, "Correct Row", row);43
function getPartner(x) {