This file contains hidden or 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
| lowest_common_ancestor = function(root, p, q) { | |
| var result = -1 | |
| var found_p = false | |
| var found_q = false | |
| var find_last_common = (dll_p, dll_q) => { | |
| var head_p = dll_p | |
| while (head_p.back) head_p = head_p.back | |
| var head_q = dll_q | |
| while (head_q.back) head_q = head_q.back |
This file contains hidden or 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
| { | |
| "uniswapV2": { | |
| "factory": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f" | |
| }, | |
| "sushiswapV2": { | |
| "factory": "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac" | |
| }, | |
| "shibaswapV2": { | |
| "factory": "0x115934131916C8b277DD010Ee02de363c09d037c" | |
| }, |
This file contains hidden or 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
| console.log([...document.getElementsByTagName('letter')].reduce( | |
| (text, $) => text + $.textContent, | |
| '' | |
| )) |
This file contains hidden or 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
| make_url = a => `https://etherscan.io/address/${a}#notes` | |
| a = new Set() | |
| Object.keys(state.exchanges.uniswap_v3).forEach(t0 => { | |
| Object.keys(state.exchanges.uniswap_v3[t0]).forEach(t1 => { | |
| a.add(state.exchanges.uniswap_v3[t0][t1]) | |
| }) | |
| }) |
This file contains hidden or 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 m = [ | |
| 'Monday', | |
| 'Tuesday', | |
| 'Wednesday', | |
| 'Thursday', | |
| 'Friday', | |
| 'Saturday', | |
| 'Sunday' | |
| ] | |
| const N = [].concat( |
This file contains hidden or 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 insert (node, x) { | |
| if (x < node.value) { | |
| if (node.left) { | |
| if (x < node.left.value) { | |
| insert(node.left, x) | |
| } else { | |
| node.left = {value: x, left: node.left} | |
| } | |
| } else { | |
| node.left = {value: x} |
This file contains hidden or 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 replace_without_case_sensitive (where, from, to) { | |
| return where.toLowerCase().split(from.toLowerCase()).reduce( | |
| (acc, _) => | |
| [ | |
| acc[0] + _.length + from.length, | |
| acc[1].concat(where.substring(acc[0], acc[0] + _.length)) | |
| ], | |
| [0, []] | |
| )[1].join(to) | |
| } |
This file contains hidden or 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 cellCompete(states, days) { | |
| if (days === 0) return states | |
| const a = new Array(states.length) | |
| states.push(0) | |
| states.unshift(0) | |
| for (var i = 1; i < states.length - 1; i++) | |
| a[i - 1] = states[i - 1] === states[i + 1] | |
| ? 0 | |
| : 1 | |
| return cellCompete(a, days - 1) |
This file contains hidden or 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 deferred = require('deferred'); | |
| var assert = require('assert'); | |
| describe('deferred', function () { | |
| it('map', function (done) { | |
| var def1 = deferred(); | |
| var def2 = deferred(); | |
| setTimeout(function () { | |
| def1.resolve(1); |
This file contains hidden or 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
| new Promise((y, n) => redis((e, db) => e ? n(e) : y(db))) |
NewerOlder