로그인 유지 기능 사용 여부와 계정 데이터를 브라우저 측에 저장합니다.
서브 키키 |
---|
ERROR #98123 WEBPACK | |
Generating JavaScript bundles failed | |
Cannot read property 'line' of undefined |
function fib(n) { | |
let first = 1, second = 0; | |
let current; | |
for (let i = 2; i <= n; i++) { | |
current = first + second | |
second = first | |
first = current | |
} | |
return current | |
} |
function nextPermutation(A: number[]) { | |
let i = A.length - 1 | |
let j = A.length - 1 | |
while (i > 0 && A[i - 1] >= A[i]) i -= 1 | |
if (i === 0) return false | |
while (A[j] <= A[i - 1]) j -= 1 |
function strToint(string: string) { | |
let i = 0; | |
let num = 0; | |
let isNeg = false; | |
const length = string.length; | |
const zeroCode = '0'.charCodeAt(0); | |
if (string[0] === '-') { | |
isNeg = true; | |
i = 1; |
function palindrome<T extends string | string[]>(array: T) { | |
for (let start = 0, end = array.length - 1; start < end; start++, end--) { | |
if (array[start] !== array[end]) return false | |
} | |
return true | |
} | |
console.assert(palindrome('HIH')) | |
console.assert(palindrome('nan nan nan')) |
const isEqual = <T extends number | string>(first: T[], second: T[]) => | |
first.length === second.length && | |
first.findIndex((item, index) => item !== second[index]) === -1; | |
const isEqualVariableArray = <T>(...arrays: T[][]) => arrays.slice(0, arrays.length - 1).findIndex((array, index) => !isEqual<T>(array, arrays[index+1])) | |
console.assert(isEqualVariableArray<number>([1, 2], [1, 2], [1, 2])) |
function selectionSort(array: number[]) { | |
for (let last = array.length - 1; last > 0; last--) { | |
const largest = array.slice(0, last + 1).sort()[last]; | |
const largestIndex = array.findIndex((item) => item === largest); | |
array[largestIndex] = array[last]; | |
array[last] = largest; | |
} | |
return array; | |
} |
import { writeFileSync } from 'fs' | |
const start = 'Thu Oct 31 2019 00:00:00' | |
const date = new Date(start) | |
const current = new Date() | |
const pad = (d: number) => (d < 10 ? '0' + d.toString() : d.toString()) | |
type NumAndPad = { num: number; pad: string } |
// orginal source: https://repl.it/@stella_sighs/dijkstramedium | |
const graph = { | |
start: { A: 5, B: 2 }, | |
A: { C: 4, D: 2 }, | |
B: { A: 8, D: 7 }, | |
C: { D: 6, finish: 3 }, | |
D: { finish: 1 }, | |
finish: {} | |
} |