let arr1 = Array.from({length: 10000000}, (_, i) => i);
Node version 15.8
- reverse method 274ms
console.log('test') |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<h1 id="selectFile"></h1> |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hello World!</title> | |
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" /> | |
</head> | |
<body> | |
<h1>Hello World!</h1> | |
<p>Drag the boxes below to somewhere in your OS (Finder/Explorer, Desktop, etc.) to copy an example markdown file.</p> |
const util = require("util") | |
function delay(time, data) { | |
return new Promise((res, rej) => { | |
setTimeout(() => res(data), time); | |
}) | |
} | |
async function *promiseMarathon(...promises) { | |
while (promises.length > 0) { |
function *permutation(arr, size = arr.length) { | |
yield *permutUntil(arr); | |
function *permutUntil(list, picked=[]) { | |
if (list.length === arr.length - size) { | |
// μνλ κΈΈμ΄λ§νΌ λ½νλκΉμ§ λ°λ³΅ | |
return yield picked; | |
} | |
for(let i=0; i<list.length; i++) { | |
let copiedList = list.slice(); // deep copy |
function forFacto(n) { | |
for(var i=1; n>0; i *= n--); | |
return i; | |
} | |
function recurFacto(n) { | |
if (n === 1) { | |
return 1; | |
} | |
return n * recurFacto(n-1); |
#include <stdio.h> | |
#include <time.h> | |
#include <math.h> | |
int timeOne(n) { | |
return n; | |
} | |
void timeN(n) { | |
while(n) { |
class Queue { | |
constructor() { | |
this.list = []; | |
this.first = null; | |
} | |
enqueue(v) { | |
if (this.first === null) { | |
this.first = v; | |
} |
class Stack{ | |
constructor() { | |
this.list = []; | |
this.top = null; | |
} | |
push(v) { | |
this.list.push(v); | |
this.top = v; | |
} |