# leetcode题解

## Learning Note of Go – Leetcode

Use of Channel package main import “golang.org/x/tour/tree” import “fmt” // Walk walks the tree t sending all values // from the tree to the channel ch. func Walk(t *tree.Tree, ch chan int){ _Walk(t, ch) close(ch) } func _Walk(t *tree.Tree, ch chan int){ if t.Left != nil{ _Walk(t.Left, ch) } ch […]

## [leetcode] Coin Change2

322. Coin Change You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, […]

## [leetcode] 310. Minimum Height Trees1

Minimum Height Trees For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called minimum height trees (MHTs). Given such a graph, write a function to find […]

## [leetcode] Range Sum Query 2D – Mutable1

Range Sum Query 2D – Mutable Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2). The above rectangle (with the red border) is defined by (row1, col1) = (2, 1) and […]

## [leetcode]Range Sum Query – Mutable

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. The update(i, val) function modifies nums by updating the element at index i to val. Example: Given nums = [1, 3, 5] sumRange(0, 2) -> 9 update(1, 2) sumRange(0, 2) […]

## [lintcode] Topological Sorting

Topological Sorting Medium Topological SortingShow result 25% Accepted Given an directed graph, a topological order of the graph nodes is defined as follow: For each directed edge A -> B in graph, A must before B in the order list. The first node in the order can be any node […]