mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 00:27:55 +00:00
Docs: Update benchmark results
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
const findLISLength = async (arr) => {
|
||||
if (!arr?.length) return 0;
|
||||
|
||||
const { bisectLeft } = await import('https://cdn.skypack.dev/d3-array');
|
||||
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm');
|
||||
|
||||
const tails = [];
|
||||
|
||||
for (const num of arr) {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
async function findLISLength(arr) {
|
||||
const { bisectLeft } = await import('https://cdn.skypack.dev/d3-array');
|
||||
const findLISLength = async (nums) => {
|
||||
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm');
|
||||
|
||||
if (!arr?.length) return 0;
|
||||
if (!nums?.length) return 0;
|
||||
|
||||
const tails = [];
|
||||
|
||||
for (const num of arr) {
|
||||
for (const num of nums) {
|
||||
const pos = bisectLeft(tails, num);
|
||||
tails[pos] = num;
|
||||
}
|
||||
|
||||
return tails.length;
|
||||
}
|
||||
};
|
||||
export default findLISLength;
|
||||
@@ -1,15 +1,15 @@
|
||||
async function findLISLength(nums) {
|
||||
if (!nums?.length) return 0;
|
||||
const findLISLength = async (nums) => {
|
||||
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm');
|
||||
|
||||
const { bisectLeft } = await import('https://cdn.skypack.dev/d3-array');
|
||||
if (!nums?.length) return 0;
|
||||
|
||||
const tails = [];
|
||||
|
||||
for (const num of nums) {
|
||||
const pos = bisectLeft(tails, num);
|
||||
tails[pos] = num;
|
||||
const idx = bisectLeft(tails, num);
|
||||
tails[idx] = num;
|
||||
}
|
||||
|
||||
return tails.length;
|
||||
}
|
||||
};
|
||||
export default findLISLength;
|
||||
@@ -1,15 +1,15 @@
|
||||
const findLISLength = async (nums) => {
|
||||
if (!nums?.length) {
|
||||
return 0;
|
||||
if (!nums?.length) return 0;
|
||||
|
||||
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm');
|
||||
|
||||
const tails = [];
|
||||
|
||||
for (const num of nums) {
|
||||
const i = bisectLeft(tails, num);
|
||||
tails[i] = num;
|
||||
}
|
||||
|
||||
const { bisectLeft } = await import("https://cdn.jsdelivr.net/npm/d3-array@3");
|
||||
|
||||
const tails = nums.reduce((sub, num) => {
|
||||
sub[bisectLeft(sub, num)] = num;
|
||||
return sub;
|
||||
}, []);
|
||||
|
||||
return tails.length;
|
||||
};
|
||||
export default findLISLength;
|
||||
@@ -1,14 +1,14 @@
|
||||
const findLISLength=async a=>{
|
||||
if(!Array.isArray(a)) throw new TypeError('Expected an array')
|
||||
const {bisectLeft:b}=await (findLISLength.m??=import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm'))
|
||||
const t=[]
|
||||
for(const v of a){
|
||||
if(!Number.isFinite(v)) throw new TypeError('Array values must be finite numbers')
|
||||
const i=b(t,v)
|
||||
if(i===t.length) t.push(v)
|
||||
else t[i]=v
|
||||
let l;
|
||||
const m=()=>l??=import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm').then(({bisectLeft})=>bisectLeft);
|
||||
export async function findLISLength(a){
|
||||
if(!Array.isArray(a)) throw new TypeError('Expected array');
|
||||
const b=await m();
|
||||
const t=[];
|
||||
for(const n of a){
|
||||
if(typeof n!=='number'||!Number.isFinite(n)) throw new TypeError('Expected finite numbers');
|
||||
const i=b(t,n);
|
||||
t[i]=n;
|
||||
}
|
||||
return t.length
|
||||
return t.length;
|
||||
}
|
||||
window.findLISLength=findLISLength
|
||||
export default findLISLength;
|
||||
Reference in New Issue
Block a user