Skip to content

Instantly share code, notes, and snippets.

@esyrt
esyrt / max_subtree.cc
Created September 18, 2012 05:26 — forked from luangong/maximum_subtree.cc
求二叉树的最大子树
#include <iostream>
#include <limits>
using namespace std;
struct Node {
int data;
Node *lchild;
Node *rchild;
};
@esyrt
esyrt / tree.md
Created May 3, 2012 07:20 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@esyrt
esyrt / RemoveMultipleSpaces.cs
Created April 1, 2012 09:28 — forked from Ninputer/RemoveMultipleSpaces.cs
模拟微面试之去空格
//请实现下面的函数,输入参数baseStr是一个(可以更改的)字符串,请将其中所有连续出现的多个空格都替换成一个空格,单一空格需保留。
//请直接使用baseStr的空间,如需开辟新的存储空间,不能超过o(N)(注意是小o,N是字符串的长度)。返回值是替换后的字符串的长度。
//样例代码为C#,但可以使用任何语言。如需使用任何库函数,必须同时给出库函数的实现。
class Program
{
public static int RemoveMultipleSpaces(char[] baseStr)
{
if (baseStr == null)
{
throw new ArgumentNullException("baseStr");