Equilibrium index: Difference between revisions
m
→ES6 Functional
(→JS ES6 Functional: Restored and updated a functional version which returns all equilibrium indices) |
m (→ES6 Functional) |
||
Line 1,309:
// ------------------------TEST------------------------
const main = () => {
console.log(JSON.stringify([
[-7, 1, 5, 2, -4, 3, 0],
[1, -1, 1, -1,
▲ ].map(equilibriumIndices)
// -> [[3, 6], [], [1], [0, 1, 2, 3, 4, 5, 6], [0], []]
};
Line 1,385 ⟶ 1,383:
ys => Array.from({
length: Math.min(xs.length, ys.length)
}, (_, i) =>
// MAIN ---
|