码迷,mamicode.com
首页 >  
搜索关键字:binary    ( 11734个结果)
LeetCode总结 -- 一维动态规划篇
这篇文章的主题是动态规划, 主要介绍LeetCode中一维动态规划的题目, 列表如下:Climbing StairsDecode WaysUnique Binary Search TreesMaximum SubarrayMaximum Product SubarrayBest Time to Bu...
分类:其他好文   时间:2015-01-30 06:35:32    阅读次数:195
Leetcode#103 Binary Tree Zigzag Level Order Traversal
原题地址基本数据结构操作,二叉树的层次遍历。代码: 1 vector > zigzagLevelOrder(TreeNode *root) { 2 vector > res; 3 vector layer; 4 bool l2r = true; 5 ...
分类:其他好文   时间:2015-01-29 20:49:11    阅读次数:169
Leetcode#95 Unique Binary Search Trees II
原题地址Unique Binary Search Trees(参见这篇文章)的升级版做题的时候我在想,这要是把每个二叉树都独立创建一份得多麻烦啊,试试能不能共用"公共部分",试了一下,果然可以,哈哈。trees[i][j]表示数字i到j所能组成的所有二叉树的根节点代码: 1 vector gener...
分类:其他好文   时间:2015-01-29 19:04:40    阅读次数:168
Leetcode#98 Validate Binary Search Tree
原题地址中序遍历二叉树,如果出现逆序对,则说明不是合法BST代码: 1 bool isValidBST(TreeNode *root) { 2 stack st; 3 int last = 0; 4 bool hasLast = false; 5 ...
分类:其他好文   时间:2015-01-29 19:01:22    阅读次数:154
[LeetCode#117]Populating Next Right Pointers in Each Node II
The problem:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous s...
分类:其他好文   时间:2015-01-29 14:00:12    阅读次数:118
二分检索,顺序检索模板
#include #include using namespace std;int cmp(const void *a, const void *b){ return ( *(int *)a - *(int *)b );}int binary_search( int *a, int n, int k...
分类:其他好文   时间:2015-01-29 12:30:55    阅读次数:117
golang产生guid
labix.org/v2/mgo/bson 包虽然是MongoDB的golang实现,其中产生唯一ID的算法是独立的,不依赖MongoDB, 提炼这部分的代码如下: package main import ( "crypto/md5" "crypto/rand" "encoding/binary" ...
分类:其他好文   时间:2015-01-29 12:16:44    阅读次数:894
Leetcode#144 Binary Tree Preorder Traversal
原题地址递归代码谁都会,当然是写非递归代码了。最基本的写法是用一个特殊栈同时保存节点以及节点的左孩子、右孩子是否遍历过。这种思路比较简单,跟递归写法一样很好理解。前序、中序、后序的遍历写法类似。还有一种更"屌"的写法,只需要使用普通栈即可,不需要保存左孩子、右孩子是否遍历过。基本思路是:1. 只要当...
分类:其他好文   时间:2015-01-29 11:50:43    阅读次数:96
LeetCode Unique Binary Search Trees II
Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 uni...
分类:其他好文   时间:2015-01-28 23:56:50    阅读次数:231
erlang里面中文相关处理
在控制台输出的话Name = "测试数据",io:format("~ts~n",[Name]).如果是和客户端通信,假如都是utf8编码服务器获取的时候,仍然可以直接通过binary_to_list解码发给客户端的数据的时候,需要用unicode:characters_to_binary("猪头")...
分类:其他好文   时间:2015-01-28 19:41:39    阅读次数:454
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!