- 博客(19)
- 收藏
- 关注
原创 宝剑升级问题
你有一把宝剑。每使用一个宝石,有50%的概率会成功让宝剑升一级,50%的概率会失败。如果宝剑的级数大于等于5的话,那么失败会使得宝剑降1级。如果宝剑的级数小于5的话,失败没有效果。问题是:期望用多少个宝石可以让一把1级的宝剑升到9级?题目源自 http://bbs.youkuaiyun.com/topics/370221989f(2) = 2;f(3) = 2;f(4)
2013-09-20 14:31:39
2235
转载 c++的单例模式
单例模式也称为单件模式、单子模式,可能是使用最广泛的设计模式。其意图是保证一个类仅有一个实例,并提供一个访问它的全局访问点,该实例被所有程序模块共享。有很多地方需要这样的功能模块,如系统的日志输出,GUI应用必须是单鼠标,MODEM的联接需要一条且只需要一条电话线,操作系统只能有一个窗口管理器,一台PC连一个键盘。 单例模式有许多种实现方法,在C++中,甚至可以直接用一个全局变量做
2013-09-19 10:37:10
448
原创 Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the f
2013-09-16 17:13:06
596
原创 Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. TreeNode *sortedArrayToBST(vector &num) { if (num.size() == 0) re
2013-09-15 23:37:01
553
原创 Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees ofevery node never diff
2013-09-15 23:15:36
649
原创 Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2]. vector inorde
2013-09-13 18:11:37
369
原创 Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3Return 6.
2013-09-09 23:07:37
509
原创 Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link
2013-09-09 11:45:33
469
原创 Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo
2013-09-09 10:42:25
501
原创 Remove Nth Node From End of List
代码有点乱,等有空再改。Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second
2013-09-05 23:42:57
411
原创 Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. int maxDepth(TreeNode *root)
2013-09-05 22:14:51
441
原创 Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and
2013-09-02 15:55:37
385
原创 Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. int minDepth(TreeNode *roo
2013-09-01 23:41:12
572
原创 Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value./** *
2013-09-01 20:45:38
448
原创 Pow(double x, int n)
Implement pow(x, n). double pow(double x, int n) { // Start typing your C/C++ solution below // DO NOT write int main() function if (n == 0) retur
2013-09-01 20:29:17
731
原创 关于ubuntu下vimgdb的安装
走了不少弯路,总算搞定了。。首先 安装相应的库安装编译工具sudo apt-get install build-essential安装编译vim-gtk的依赖包sudo apt-get build-dep vim-gtk安装ncurses开发包sudo apt -get install libncurses5-dev然后下载vim-7.3
2012-12-05 16:34:32
1454
转载 win7+64位+Oracle+11g+64位下使用PLSQL+Developer+的解决办法
1)安装Oracle 11g 64位 2)安装32位的Oracle客户端( instantclient-basic-win32-11.2.0.1.0) 下载instantclient-basic-win32-11.2.0.1.0.zip (一定得是32位的,不要下错了版本,Oracle官网有下载),将其解压至Oracle安装目录的Product下(本机命名为:instant
2012-09-30 15:10:34
325
转载 突破IP封锁,共享网络
凌晨,我掰扯着惺忪的睡眼,怀着不成功便成仁的悲壮,刷了两台路由器的固件。一台是我以前使用的tp-402m,一台是正在使用的磊科205+。从网上分别找了最新的固件,令人难以相信的是这两个固件居然都是专门写给山东用户,用于防网通屏蔽的。 我解压缩后,开始进入路由器准备准备升级。可是,输入“192.168.1.1”,怎么也进不去管理界面了。摆弄了很长时间,还是不行。难道tp-402m就这
2012-09-14 21:14:18
3352
1
转载 重装win7之后没有ubuntu启动选项的解决方案
安装win7后,需要通过光盘来修复比较方便,如果不用盘也可以在win7系统中,硬盘启动ubuntu镜像,来进行修复操作,具体步骤如下,从ubuntu9.10或者10.04版的安装光盘启动之后,进入终端,先在终端输入命令:sudo fdisk -l (注意是小写的L,不是数字的1,此步用于确定电脑中安装Ubuntu的所在分区的位置,输入以后会输出类似如下信息,找到ID为83的那行,记住/dev/
2012-09-08 23:43:25
420
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人