const SIZE = 20000;
const baseArr = Array.from({ length: SIZE }, (_, i) => i);
function buildSingly(arr) {
let head = { val: arr[0], next: null };
let curr = head;
for (let i = 1; i < arr.length; i++) {
curr.next = { val: arr[i], next: null };
curr = curr.next;
}
return head;
}
function buildDoubly(arr) {
let head = { val: arr[0], next: null, prev: null };
let curr = head;
for (let i = 1; i < arr.length; i++) {
const node = { val: arr[i], next: null, prev: curr };
curr.next = node;
curr = node;
}
return head;
}Initializing...
| Test Case | Ops/sec | |
|---|---|---|
| arr | | ready |
| singly Llist | | ready |
| double Llist | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.