Skip to content

Instantly share code, notes, and snippets.

View JackyChiu's full-sized avatar

Jacky Chiu JackyChiu

View GitHub Profile
@JackyChiu
JackyChiu / pathsum.py
Created October 31, 2019 02:24
testing
# https://leetcode.com/problems/path-sum-iii/
# Given a binary tree and a number ‘S’, find all paths in the tree such that the
# sum of all the node values of each path equals ‘S’. Please note that the paths
# can start or end at any node but all paths must follow direction from parent to
# child (top to bottom).
# 1
# /\
# 7 9
# @param {String} s
# @return {Integer}
def length_of_longest_substring(s)
chars = s.split('')
longest = 0
base = 0
char_set = Set.new
(base...chars.length).each do |iter|
@JackyChiu
JackyChiu / matcher.go
Created December 3, 2018 21:10
Pattern Matcher
package main
// Match accepts a pattern and a string. It will do a full string match base on
// the following rules:
//
// - A non-special character in a pattern matches only that character.
// - The special-character `.` in the pattern matches any single character.
// - The special-character `?` in the pattern does not match any character, but
// indicates the following character in the pattern can match zero or one times.
// - The special-character `*` in the pattern does not match any character, but
package main
import (
"context"
"log"
"time"
"cloud.google.com/go/pubsub"
"cloud.google.com/go/pubsub/pstest"
"google.golang.org/api/option"
@JackyChiu
JackyChiu / firefox.sh
Last active April 25, 2018 04:22
MacOS: Setup a Symlink for your userChrome.css
#/bin/bash
profiles=~/Library/Application\ Support/Firefox/Profiles
if ! [[ -d $profiles ]]; then
echo "Looks like firefox isn't installed"
exit 1
fi
for dir in $(ls "$profiles"); do
[[ $dir != *default ]] && exit 1
// Requirements
//
//
// Read all orders from the paginated API.
// Any order without cookies can be fulfilled.
// Prioritize fulfilling orders with the highest amount of cookies.
// If orders have the same amount of cookies, prioritize the order with the lowest ID.
// If an order has an amount of cookies bigger than the remaining cookies, skip the order.
//
//