Bloomberg - Front end - Phone Screen

Equiv function to group array of groups together
Grouping Equivalence Classes
Why hooks => because it replaces the class component lifecycle (component did mount)
useContext vs redux
Asked me graph ql
System design: develop an api
Asked about playwright, mention it works in pipeline too and coverage
function groupEquiv(arr, equiv) {
const groups = ;
for (let i = 0; i < arr.length; i++) {
let placed = false;
for (let g = 0; g < groups.length; g++) {
if (equiv(arr[i], groups[g][0])) {
groups[g].push(arr[i]);
placed = true;
break;
}
}
if (!placed) {
groups.push([arr[i]]);
}
}
return groups;
}
const input = [1, 2, 3, 4, 5, 6];
groupEquiv(input, (a, b) => a % 2 === b % 2); // [[1,3,5],[2,4,6]]
groupEquiv(input, (a, b) => a + b === 7); // [[1,6],[2,5],[3,4]]
groupEquiv(input, (a, b) => a > 3 && b > 3); // [[1],[2],[3],[4,5,6]]
groupEquiv(input, (a, b) => a === b); // [[1],[2],[3],[4],[5],[6]]