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
/** | |
* @param {number[]} nums | |
* @param {number} target | |
* @return {number[]} | |
*/ | |
var twoSum = function(nums, target) { | |
for (let [i1, v1] of nums.entries()) { | |
for (let [i2, v2] of nums.entries()) { | |
if (i1 !== i2) { | |
if (v1+v2 === target) return [i1, i2] |
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
/** | |
* @param {number} x | |
* @return {number} | |
*/ | |
var reverse = function(x) { | |
let result = 0 | |
let number = Math.abs(x) | |
for (let i of [...new Array(number.toString().length)].map((e, index) => Number("1" + "0".repeat(index))).reverse()) { | |
result += (number % 10) * i |
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
/** | |
* @param {number} x | |
* @return {boolean} | |
*/ | |
var isPalindrome = function(x) { | |
return x.toString().split("").reverse().join("") === x.toString() | |
}; |
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
/** | |
* @param {string} s | |
* @return {number} | |
*/ | |
var romanToInt = function(s) { | |
const symbols = { | |
"I": 1, | |
"V": 5, | |
"X": 10, | |
"L": 50, |
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
/** | |
* @param {number} numRows | |
* @return {number[][]} | |
*/ | |
var generate = function(numRows) { | |
const p = [] | |
p[0] = [1] | |
p[1] = [1, 1] | |
if (numRows === 1) return p[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
const questions = [ | |
"What is your favorite programming language?", | |
"Where do you work?", | |
"Do you like Node JS?" | |
] | |
const collectAnswers = (questions, done) => { | |
const readline = require("readline") | |
const rl = readline.createInterface({ | |
input: process.stdin, |
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 sum (n) { | |
if (n === undefined) return 0 | |
let inc = n | |
function add (k) { | |
if (k === undefined) return inc | |
inc += k | |
return add | |
} |
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
project: { | |
'/': { | |
name: null, | |
path: null, | |
childrenFolders: ['/public/', '/src/', '/node_modules/'], | |
files: [ | |
{ | |
name: 'package.json', | |
path: '/', | |
}, |