View Heap.min.js
function Heap(n=((n,t)=>n-t)){const t=[];return{push:function(o){t.push(o),function(){let o=t.length-1,e=o-1>>1;for(;0!==o&&n(t[o],t[e])<0;)[t[o],t[e]]=[t[e],t[o]],e=(o=e)-1>>1}()},pop:function(){const e=o(),u=t.pop();t.length>0&&(t[0]=u,function(){let o=0;for(;;){let e=o;for(const u of[2*o+1,2*o+2])u<t.length&&n(t[u],t[e])<0&&(e=u);if(e===o)return;[t[o],t[e]]=[t[e],t[o]],o=e}}());return e},peek:o};function o(){return t[0]}}
View Heap.js
function Heap(compare = (a, b) => a - b) {
const arr = [];
return { push, pop, peek };
function push(v) {
arr.push(v);
bubble();
}
function pop() {
View LRU.js
var LRUCache = function(capacity) {
// beofre <--> { k0, v0 } <--> { k1, v1 }
const map = {}; // map key to node
const before = {};
let count = 0;
let tail = before;
return { get, put };
function get(k) {
View 400.java
public class Solution {
public int findNthDigit(int n) {
int digitCount = 1;
long threshold = 9 * (long)Math.pow(10, digitCount - 1) * digitCount;
while (n > threshold) {
n -= threshold;
threshold /= digitCount;
threshold *= 10 * (++digitCount);
}
View Note.md

Notes

  • HTML5 history API
View test.py
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def reverseList(self, head):
prev = None
View snapchat.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.js">
</script>
<style>
View 84.js
/**
* @param {number[]} heights
* @return {number}
*/
function largestRectangleArea(heights) {
heights.push(-1);
var stack = [];
var max = 0;
heights.forEach((h, i) => {