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
export INSTANCE_NAME="my-tf2-instance" | |
export ZONE="us-central1-c" | |
export IMAGE_FAMILY="tf2-latest-gpu" | |
export INSTANCE_TYPE="n1-highmem-4" | |
export ACCELERATOR="type=nvidia-tesla-k80,count=1" | |
gcloud compute instances create $INSTANCE_NAME \ | |
--zone=$ZONE \ | |
--image-family=$IMAGE_FAMILY \ | |
--image-project=deeplearning-platform-release \ |
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
export IMAGE_FAMILY="tf2-latest-gpu" # or "tf2-latest-cpu" for non-GPU instances | |
export ZONE="us-west1-b" # budget: "us-west1-b", richer: us-west2-b | |
export INSTANCE_NAME="my-tf2-instance" | |
export INSTANCE_TYPE="n1-highmem-4" # budget: "n1-highmem-4", richer: n1-highmem-8 | |
# budget: type=nvidia-tesla-k80,count=1 | |
# richer: type=nvidia-tesla-p4,count=1 | |
export ACCELERATOR="type=nvidia-tesla-k80,count=1" | |
gcloud compute instances create $INSTANCE_NAME \ | |
--zone=$ZONE \ |
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 java.util.ArrayList; | |
import java.util.LinkedList; | |
import java.util.List; | |
public class CBTInserter { | |
private TreeNode root = null; | |
private List<TreeNode> memo = new ArrayList<>(); | |
public CBTInserter(TreeNode root) { | |
this.root = root; |
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
public class CBTCheck { | |
private int[] walk(TreeNode root) { | |
if (root == null) { return new int[]{0, 0, 1}; } // min, max, valid | |
int[] left = walk(root.left); | |
int[] right = walk(root.right); | |
int valid = left[2] & right[2]; | |
if (right[1] > left[1]) { | |
valid = 0; | |
} else if (right[1] + 1 < left[1]) { | |
valid = 0; |
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
public class TreeNode { | |
int val; | |
TreeNode left; | |
TreeNode right; | |
TreeNode(int x) { val = x; } | |
} | |
public class CBTNodeCount { | |
private int getHeight(TreeNode root) { | |
if (root == null) { return 0; } |
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
public class CatalanNumbers { | |
public int numPatterns(int n) { | |
double count = 1.0; | |
for (double i = 1.0; i <= n; i += 1.0) { | |
count *= ((i + n) / i); | |
} | |
return (int) Math.round(count / (n + 1)); | |
} | |
public int numPatternsDP(int n) { |
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
;; A solution and test code for https://www.hackerrank.com/challenges/30-dictionaries-and-maps/problem | |
;; test/thirty-days-code.core_test.clj | |
(ns thirty-days-code.core-test | |
(:require [clojure.java.io :as io] | |
[clojure.test :refer :all])) | |
(defn wrap-test [n f] | |
(with-open [rdr (io/reader (io/resource n))] | |
(binding [*in* rdr] |
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
# https://en.wikibooks.org/wiki/Japanese/Transcribing_English_to_Japanese | |
import os | |
import sys | |
sys.path.append(os.path.abspath('./English-to-IPA')) | |
from pykakasi import kakasi | |
import romkan | |
import eng_to_ipa as ipa | |
import re |
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
""" | |
Description: | |
Given a string, find the length of the longest substring T that contains at most k | |
distinct characters. | |
Examples: | |
Input: s = "eceba", k = 2 | |
Output: 3 -- 'ece' is the longest | |
Input: s = "aa", k = 1 |
NewerOlder