Skip to content

Instantly share code, notes, and snippets.

View j-quelly's full-sized avatar

Jamie Kelly j-quelly

View GitHub Profile
@j-quelly
j-quelly / swapLexOrder.js
Created January 10, 2019 03:42
Given a string str and array of pairs that indicates which indices in the string can be swapped, return the lexicographically largest string that results from doing the allowed swaps. You can swap indices any number of times.
function quickSort(nums) {
// base case
if (nums.length <= 1) {
return nums;
}
// grab a pivot
const pivot = nums.pop();
// divide
function get(object, prop, notFound = undefined) {
if (object) {
if (prop in object) {
return object[prop];
}
}
return notFound;
}
function depthFirst(tree, order, isNotSymmetrical, callback) {
@j-quelly
j-quelly / queue.js
Last active February 17, 2019 04:24
// files to queue
let filesToProcess = [
'file1',
'file2',
'file3',
'file4',
'file5',
'file6',
'file7',
'file8',
class Node:
def __init__(self, value):
self.value = value
self.next = None
class Queue:
def __init__(self):
self.head = None
@j-quelly
j-quelly / countClouds.js
Created August 13, 2019 18:20
count clouds
function sweepClouds({ skyMap, y, x }) {
if (!skyMap[y]) {
return;
}
if (!skyMap[y][x]) {
return;
}
if (skyMap[y][x] === '1') {