View exportjson.js
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
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible). | |
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export. | |
var FORMAT_ONELINE = 'One-line'; | |
var FORMAT_MULTILINE = 'Multi-line'; | |
var FORMAT_PRETTY = 'Pretty'; | |
var LANGUAGE_JS = 'JavaScript'; | |
var LANGUAGE_PYTHON = 'Python'; |
View OfferManager.sol
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
//SPDX-License-Identifier: Unlicense | |
pragma solidity ^0.7.0; | |
import "@openzeppelin/contracts/utils/Counters.sol"; | |
import "@openzeppelin/contracts/utils/EnumerableSet.sol"; | |
library OfferManager { | |
using EnumerableSet for EnumerableSet.UintSet; | |
using EnumerableSet for EnumerableSet.AddressSet; | |
using Counters for Counters.Counter; |
View MergeSort.js
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 MergeSort() { } | |
MergeSort.prototype.sort = function(values) { | |
if (values.length < 2) { | |
return values; | |
} | |
var mid = Math.floor(values.length/2); | |
var left = this.sort(values.slice(0, mid)); | |
var right = this.sort(values.slice(mid, values.length)); |
View LRUCache.js
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
// LRUCache.js - super simple JavaScript Implementation | |
// LRU stands for "Least Recently Used" | |
// https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU | |
// ----------------------------------------- | |
function LRUNode(key) { | |
this.key = key; | |
this.next = this.prev = null; | |
} |
View Trie.js
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
// Trie.js - super simple JS implementation | |
// https://en.wikipedia.org/wiki/Trie | |
// ----------------------------------------- | |
// we start with the TrieNode | |
function TrieNode(key) { | |
// the "key" value will be the character in sequence | |
this.key = key; | |
View graph.js
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
// Implement a Graph | |
// basic operations: | |
// - add vertex (node) | |
// - add edge (node -> node) | |
function GraphNode(val) { | |
this.val = val; | |
this.edges = {}; | |
} |
View queue.js
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
// Implement a Queue using LinkedLists | |
// we know that queue is LIFO | |
// operations: enqueue, dequeue | |
function QueueNode(val) { | |
this.val = val; | |
this.next = null; | |
} | |
function Queue() { |
View stack.js
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
// Implement a stack using LinkedLists. | |
// Operations: | |
// -> push | |
// -> pop | |
// -> peek | |
function StackNode(val) { | |
this.val = val; | |
this.next = null; |
View minHeap.js
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
// Implement a min heap: | |
// -> insert, extract_min | |
// property: | |
// - elements are in ascending order | |
// - complete binary tree (node is smaller than it’s children) | |
// - root is the most minimum | |
// - insert takes O(logn) time | |
// - insert to the bottom right |
View BSTree.swift
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 Foundation | |
class Node { | |
var val: Int | |
var left: Node? | |
var right: Node? | |
NewerOlder