自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(6)
  • 收藏
  • 关注

原创 面向对象的堆实现

自己写的小根堆类发现一个问题:堆并没有不允许出现重复元素这个性质,之前一直有错误的印象当类中含有vector数据成员时,构造函数怎么写?答案是不写,交给vector的默认构造函数处理.#include #include using namespace std;templateclass MinHeap{ //int* heap; /

2014-03-30 16:06:52 378

原创 编程之美3.8:求二叉树节点的最大距离

下面的分析不局限于二叉树,而是以多叉树为例。一棵树上距离最长的两个结点的可能情况有两种:1.这两个节点位于根节点的同一棵子树上;2.这两个节点位于根节点的两棵不同的子树上。 我的想法,不使用深度优先遍历,而是改用后序遍历多叉树,树的节点包含两个特殊值:root2node和node2nodestruct ListNode { int val; int ro

2014-03-29 23:35:47 719

原创 LeetCode: Binary Tree Preorder Traversal

Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3]. Note: Recursive solu

2014-03-20 13:56:51 311

原创 LeetCode: Binary Tree Level Order Traversal II

Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree {3,9,20,#,#,15,7},

2014-03-20 12:06:25 455

原创 LeetCode OJ: Binary Tree Postorder Traversal

转战LeetCode,开始不适应,只好先从简单的题目开始Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return

2014-03-20 10:47:53 359

原创 算法导论 第15章 动态规划之钢条切割

Python代码import numpyimport copya = [0, 1, 5, 8, 9, 10, 17, 17, 20, 24, 30] #不同长度钢条的价格表,a[k]对应于长度为k的刚条的价格assert len(a) == 11cost = numpy.zeros(shape=101, dtype=int)N = 100 #待求长度K = 10 #价格表长度pattern_d

2014-03-04 23:03:03 548

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除