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 java.util.Iterator; | |
import java.util.NoSuchElementException; | |
import junit.framework.TestCase; | |
public class DequeTest extends TestCase { | |
Deque<Integer> deque; | |
protected void setUp() throws Exception { | |
super.setUp(); | |
deque = new Deque<Integer>(); |
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 java.util.Iterator; | |
import java.util.NoSuchElementException; | |
import junit.framework.TestCase; | |
public class RandomizedQueueTest extends TestCase { | |
RandomizedQueue<Integer> ran; | |
public void setUp() throws Exception { | |
super.setUp(); | |
ran = new RandomizedQueue<Integer>(); |
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 lotteryNum() { | |
return (Math.round(Math.random() * 100) % 58) + 1; | |
} | |
function pickNumber(numbers) { | |
let newNumber; | |
let found; | |
do { | |
newNumber = lotteryNum(); | |
found = numbers.find(number => newNumber === number); |
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 numJewelsInStones = (jewels, stones) => { | |
const cache = {}; | |
for (const j of jewels) { | |
cache[j] = 0 | |
} | |
for (const s of stones) { | |
if (s in cache) { | |
cache[s]++; |
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
# code --list-extensions | xargs -L 1 echo code --install-extension | |
code --install-extension asvetliakov.snapshot-tools | |
code --install-extension burkeholland.simple-react-snippets | |
code --install-extension CoenraadS.bracket-pair-colorizer | |
code --install-extension dbaeumer.vscode-eslint | |
code --install-extension donjayamanne.githistory | |
code --install-extension eamodio.gitlens | |
code --install-extension esbenp.prettier-vscode | |
code --install-extension liximomo.sftp | |
code --install-extension mermade.openapi-lint |
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 createMinHeap = () => { | |
const items = []; | |
const percolateUp = index => { | |
const parent = Math.floor((index - 1) / 2); | |
if (index > 0 && items[parent] > items[index]) { | |
[items[parent], items[index]] = [items[index], items[parent]]; | |
percolateUp(parent); | |
} |
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 chars = [ 'j','a','v','a','s','c','r','i','p','t' ]; | |
const ascii = chars.map(chr => chr.charCodeAt(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 chars = [ 'j','a','v','a','s','c','r','i','p','t' ]; | |
const justAs = chars.filter(chr => chr === 'a'); |
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 numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]; | |
const total = numbers.reduce((sum, number) => sum + number); |
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 numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]; | |
const total = numbers.reduce((sum, number) => { | |
const currentTotal = sum + number; | |
return currentTotal; | |
}, 0); |
OlderNewer