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 sweepClouds({ skyMap, y, x }) { | |
if (!skyMap[y]) { | |
return; | |
} | |
if (!skyMap[y][x]) { | |
return; | |
} | |
if (skyMap[y][x] === '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
class Node: | |
def __init__(self, value): | |
self.value = value | |
self.next = None | |
class Queue: | |
def __init__(self): | |
self.head = None |
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
// files to queue | |
let filesToProcess = [ | |
'file1', | |
'file2', | |
'file3', | |
'file4', | |
'file5', | |
'file6', | |
'file7', | |
'file8', |
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 get(object, prop, notFound = undefined) { | |
if (object) { | |
if (prop in object) { | |
return object[prop]; | |
} | |
} | |
return notFound; | |
} | |
function depthFirst(tree, order, isNotSymmetrical, callback) { |
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 quickSort(nums) { | |
// base case | |
if (nums.length <= 1) { | |
return nums; | |
} | |
// grab a pivot | |
const pivot = nums.pop(); | |
// divide |
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 groupingDishes(dishes) { | |
const ingredientMap = dishes.reduce((map, dish) => { | |
dish.slice(1).forEach((ingredient) => { | |
if (!map[ingredient]) { | |
map[ingredient] = [dish[0]]; | |
} else { | |
// if happens more than once it should be an ingredient | |
map[ingredient].push(dish[0]); | |
} | |
}); |
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
// Definition for singly-linked list: | |
// function ListNode(x) { | |
// this.value = x; | |
// this.next = null; | |
// } | |
// | |
function getArryFromList(l) { | |
let current = l; | |
const results = []; | |
while(current) { |
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
// Definition for singly-linked list: | |
// function ListNode(x) { | |
// this.value = x; | |
// this.next = null; | |
// } | |
// | |
function reverseNodesInKGroups(l, k) { | |
let temp = k; | |
let current = l; | |
const results = []; |
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
// Definition for singly-linked list: | |
// function ListNode(x) { | |
// this.value = x; | |
// this.next = null; | |
// } | |
// | |
function mergeTwoLinkedLists(l1, l2) { | |
const list = []; | |
let left = l1; | |
let right = l2; |
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
// Definition for singly-linked list: | |
// function ListNode(x) { | |
// this.value = x; | |
// this.next = null; | |
// } | |
// | |
function getNumber(list) { | |
let current = list; | |
let num = []; |
NewerOlder