Skip to content

Instantly share code, notes, and snippets.

Idea

# stack: a stack that store the current combination
# items: available items, each item has a value
# available_space: the spaces left of the current combination
# index: the index of items it is going to match
function find_combinations_recursively(stack, items, available_space, index):
    # check for invalid target or value
    value = items[index]

Define Node

static class Node {
    int value;
    Node left, right;
}

Depth First Recursive Traversal (Pre-order)

@nickwph
nickwph / install-sublime-text-3.sh
Last active October 12, 2015 18:16
Sublime Text 3 on CentOS / RHEL
#!/bin/sh
# run this to install
# sudo su install-sublime-text-3.sh
# modify this if you need another version or or architecture
URL="http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3083_x64.tar.bz2"
SHORTCUT="[Desktop Entry]
Name=Sublime Text 3
Comment=Edit text files
# node structure
class Node:
value = None
left = None
right = None
# constructor
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
import java.util.Scanner;
public class Solution1 {
public static void main(String[] args) {
try {
// read in matrix
Scanner scanner = new Scanner(System.in);
int length = Integer.parseInt(scanner.nextLine());
int[][] matrix = new int[length][length];
for (int i = 0; i < length; i++) {
@nickwph
nickwph / build-jacoco.gradle
Created May 26, 2015 23:50
Gradle build file to set up variables for JaCoCo.
/**
* Created by Nicholas Wong <nickwph@yahoo-inc.com>.
* Gradle build file to set up variables for JaCoCo.
* The following tasks will be created in normal circumstance.
*
* - Create JaCoCo HTML and XML Reports
* jacocoDebug
* jacocoRelease
*
* - Open JaCoCo HTML Report in Mac OSX