mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 11:21:00 +00:00
13 lines
498 B
JavaScript
13 lines
498 B
JavaScript
async function findLISLength(arr) {
|
|
if (!Array.isArray(arr)) throw new TypeError("Expected an array of numbers");
|
|
const { bisectLeft } = await import("https://cdn.jsdelivr.net/npm/d3-array@3/+esm");
|
|
const tails = [];
|
|
for (const n of arr) {
|
|
if (typeof n !== "number" || Number.isNaN(n)) throw new TypeError("Array must contain only valid numbers");
|
|
tails[bisectLeft(tails, n)] = n;
|
|
}
|
|
return tails.length;
|
|
}
|
|
export default findLISLength;
|
|
// Generation time: 7.363s
|
|
// Result: PASS
|