d3.unconf gist.
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
license: mit | |
border: yes |
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 | |
* @return {number} | |
*/ | |
var lengthOfLIS = function(nums) { | |
if (!nums || !nums.length) { return 0 } | |
var increasingSubsequences = []; | |
var maxSubsequence = { | |
length: 0, | |
index: 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
var detectGraphCycles = function(graph, rootId) { | |
if (typeof graph[rootId] === 'undefined') { return false }; | |
var currentNode = graph[rootId]; | |
var visited = {}; | |
var graphHasCycles = false; | |
while (currentNode && currentNode.next) { | |
if (typeof currentNode.id !== 'undefined') { | |
if (visited[currentNode.id] === true) { | |
currentNode = false; |
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
let promises = []; | |
console.log("Displaying promises as they resolve, without proper order:") | |
for (let i = 0; i < 10; i++) { | |
let myPromise = new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log(i); | |
resolve(i); | |
}, Math.floor(Math.random() * 5000)); |