This file contains hidden or 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
# Given a phone number that contains digits from 2–9, find all possible letter | |
# combinations the phone number could translate to. | |
# | |
# Example | |
# Input: "56" | |
# Output:["jm","jn","jo","km","kn","ko","lm","ln","lo"] | |
# | |
# Approach explanation | |
# All possible combinations: backtracking | |
# input.size * number of letters => 5,6 => 3*3 => 9 |
This file contains hidden or 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
package main | |
import ( | |
"crypto/sha256" | |
"encoding/hex" | |
"errors" | |
"fmt" | |
"io" | |
"github.com/shengdoushi/base58" |
This file contains hidden or 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
sealed trait Expr | |
case class BinOp(left: Expr, op:String, right: Expr) extends Expr | |
case class Literal(value: Int) extends Expr | |
case class Variable(name: String) extends Expr | |
trait ExprParser[T] { def parse(s: String): T } | |
object ExprParser { | |
implicit object ParseLiteral extends ExprParser[Literal] { | |
def parse(s: String): Literal = Literal(s.toInt) | |
} |
This file contains hidden or 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
package array | |
const DefaultCapacity int = 10 | |
type Array struct { | |
capacity int | |
size int | |
items []interface{} | |
} |
This file contains hidden or 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
class Node(): | |
def __init__(self): | |
self.children = {} | |
self.last = False | |
def __str__(self): | |
str(self.children.keys()) | |
class Trie(): | |
def __init__(self): |
This file contains hidden or 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
require 'test/unit' | |
#Every number in Pascal's triangle is calculated by adding the numbers to the left and right of it from | |
#the row above it. For example, the first 4 in the 5th row is found by | |
#adding the 1 and the 3 from above it in the 4th row. | |
# | |
#Write a function pascal(n) that calculates the nth row of Pascal's Triangle, | |
#and return it as an array of integers. | |
def solution(n) |
This file contains hidden or 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
KEY_A=value-a | |
KEY_B=value-b | |
KEY_C=value-c | |
DB_HOST=postgres.database.com | |
DB_PASSWORD=dr.i,G<I=!B3f[U8Qg%z9oP}FqYn\r |
This file contains hidden or 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
package main | |
import "log" | |
type Node struct { | |
Left *Node | |
Right *Node | |
Value int | |
} |
This file contains hidden or 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
# Node | |
class Node | |
attr_accessor :value, | |
:height, | |
:left, | |
:right | |
def initialize(value = nil, height = 0) | |
@value = value | |
@height = height |
This file contains hidden or 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
… | |
http { | |
… | |
server { | |
… | |
location /render_imgur { | |
mruby_content_handler_code ' | |
images_from_imgur = ["OiZvLe0b", "3xEanY9b", "JedUbc1b"] |