leetcode 之Binary Tree Postorder Traversal
摘要:题目描述: Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, return [3,2,1]. 即 给定一颗二叉树。 使
阅读全文
leetcode 之 Permutation
摘要:描述: 其实我没有看到这个题 给定一个数n, 求其全排列。 如3 则输出 [1, 2, 3][1, 3, 2][2, 1, 3][2, 3, 1][3, 1, 2][3, 2, 1] 使用回溯法求解。 使用n维数组visit 来标记一个数是否已经加入集合。回溯树如下: 深度优先搜索,当搜索深度为n时
阅读全文
leetcode 之 Next Permutation
摘要:题目描述: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not
阅读全文
leetcode之Unique Binary Search Trees
摘要:题目描述: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example, Given n = 3, there are a total of 5 uniq
阅读全文
c++ 非常量引用产生临时对象
摘要:在c++中,一下几种情况会产生临时对象: 1. 按值进行函数参数传递时 2. 函数返回对象时 3. 发生类型转化时。 c++中产生的临时对象是不可修改的,及默认为const的 非常量引用产生临时对象: 这里upper 函数的操作是将str转换为大写,而在进行了上面代码的调用时,发生了类型转化,产生临
阅读全文
redis的启动脚本
摘要:1 #!/bin/sh 2 # 3 # chkconfig: - 39 35 4 # description: start and stops redis server 5 # programname: redis 6 7 # Source function library. 8 if [ -f /etc/init.d/functions ] ; then ...
阅读全文
leetcode 之 Insertion Sort List
摘要:题目描述: 难度: 中等 Sort a linked list using insertion sort. 中文描述: 使用插入排序对一个链表进行排序. 解析: 插入排序就不多说了,主要看插入排序对于单链表来说怎么做. 在单链表中,由于无法拿到链表的前一个元素,所有每次遍历必须从head 开始.找到
阅读全文
leetcode 之 Product of Array Except Self
摘要:原问题描述: 难度: 中等 Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements o
阅读全文
一致性hash的由来和原理
摘要:http://blog.codinglabs.org/articles/consistent-hashing.html 在分布式缓存系统中, 如何把数据映射到不同的缓存服务器上,一般会采用hash算法,如共有3台缓存服务器时, h= Hash(key)%3, 这种hash算法的扩展性和容错性不好,当
阅读全文
我的vim 配置
摘要:set nocompatible " be iMproved filetype off " required! set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " let Vundle manage Vundle " required! Bundle 'gmarik/...
阅读全文