This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Необходимо реализовать функцию singleChange(str1, str2) -> boolean, которая проверяет, можно ли две переданные на вход строки сделать идентичными за 1 изменение | |
* (добавление / удаление / замену 1 символа) в любом месте строки. | |
* Можно не задумываться об оптимальности, просто хочется увидеть продакшен-решение. | |
Optional: юнит-тесты | |
Optional: оптимальное решение | |
* Например: | |
* singleChange('aa_a', 'ab_a') -> true (b заменяем на a) | |
* singleChange('cat', 'catt') -> true (добавляем t) | |
* singleChange('dog', 'dlog') -> true (добавляем l) | |
* singleChange('horse', 'hors') -> true (удаляем e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Hamster() {} | |
Hamster.prototype.food = []; | |
Hamster.prototype.feed = function (item) { | |
this.food.push(item); | |
}; | |
const speedy = new Hamster(); | |
const lazy = new Hamster(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"fileSize":338696, | |
"docType":"spreadsheet", | |
"coreType":".wasm", | |
"@timestamp":"2023-01-06T13:52:34.084Z", | |
"os":"mac", | |
"browser":"chrome", | |
"browser_version":"108.0.0.0" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
type Props = { | |
items: { | |
id: string; | |
name: string; | |
}[]; | |
}; | |
// items.length = 100000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Gender { | |
Male, | |
Female | |
Other | |
} | |
console.log(Gender.Male); // ?? | |
console.log(Gender[1]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs/promises' | |
function write(){ | |
return fs.mkdir('./tmp').then(function(){ | |
fs.writeFile('./tmp/foo.txt', 'Hello World'); | |
}).catch((err) => { | |
/// handle error | |
console.log(err); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs'; | |
const stream = fs.createReadStream('./sample.txt'); | |
stream.on('data', () => console.log(1)); | |
setTimeout(() => console.log(2)); | |
for (let i = 0; i < 1000000; i++) { // 10s | |
/*code*/ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* range(start, end) { | |
for (let i = start; i <= end; i++) { | |
yield i; | |
} | |
} | |
function getNoun(number, one, two, five) { | |
let n = Math.abs(number); | |
n %= 100; | |
if (n >= 5 && n <= 20) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs').promises; | |
function write(){ | |
return fs.mkdir('./tmp').then(function(){ | |
fs.writeFile('./tmp/foo.txt', 'Hello World'); | |
}).catch((err) => { | |
/// handle error | |
console.log(err); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelector('body').addEventListener('click', () => console.log(1)); | |
setTimeout(() => console.log(2), 0); | |
for (var i = 0; i < 1000000000000; i++) {/*code*/} | |
console.log(3); |
NewerOlder