码迷,mamicode.com
首页 >  
搜索关键字:binary tree maximum    ( 26821个结果
LeetCode - Best Time to Buy and Sell 3
这道题在前两个的基础上做稍微改进就可以。下面是AC代码: 1 /** 2 * Design an algorithm to find the maximum profit. You may complete at most two transactions. 3 * @pa...
分类:其他好文   时间:2014-07-22 23:01:13    阅读次数:251
哈夫曼树 POJ 3253 Fence Repair
竟然做过原题,一眼看上去竟然没感觉。。。 哈夫曼树定义:给定n个权值作为n个叶子结点,构造一棵二叉树,若带权路径长度达到最小,称这样的二叉树为最优二叉树,也称为哈夫曼树(Huffman tree)。哈夫曼树是带权路径长度最短的树,权值较大的结点离根较近。 1、路径和路径长度 在一棵树中,从一个结点往下可以达到的孩子或孙子结点之间的通路,称为路径。通路中分支的数目称为路径长度。若规...
分类:其他好文   时间:2014-07-22 22:59:32    阅读次数:293
Ubuntu 下matlab 查看memory函数
function checkmemory%Copyright (c) 2014,Lv Qi%All rights reserved.%%Redistribution and use in source and binary forms, with or without modification, a...
分类:其他好文   时间:2014-05-10 20:07:52    阅读次数:413
[leetcode] Best Time to Buy and Sell Stock II
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a...
分类:其他好文   时间:2014-05-06 00:51:29    阅读次数:353
sed
sed‘s/^/\//g‘4行首增加指定字符提取网页中的播放地址:#!/bin/bash printf"enteryourdir:" readdir echo"$dirisxx" cd$dir echo`pwd` forfilein`ls.` do if[-d$file];then echo$file cd$file echo`pwd` tree`pwd`|grepplay|sed‘s/.*//g‘>11 tree`pwd`|grepplay|sed‘s/.*//g..
分类:其他好文   时间:2014-05-03 00:53:15    阅读次数:336
线段树入门小结
QUE:线段树?称谓:从刘汝佳的书中得知,“这种数据结构在学术界没有统一的术语,但线段树是最常见的叫法。其他叫法包括区间树(interval tree)、范围树(range tree)等,但这些属于在特定的场合(如计算几何)中有着特殊的意义”。怎么叫看读者的心情,以下统一用线段树称呼。先来作一些了解...
分类:其他好文   时间:2014-05-02 16:21:56    阅读次数:347
Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only n...
分类:其他好文   时间:2014-05-02 15:03:57    阅读次数:386
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...
分类:其他好文   时间:2014-05-02 07:05:08    阅读次数:311
LeetCode5:Longest Palindromic Substring
题目: Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique lo...
分类:其他好文   时间:2014-05-01 20:07:13    阅读次数:429
数据结构《17》---- Ternary Search Tree
一、 序言 上一篇文章中,给出了 trie 树的一个实现。可以看到,trie 树有一个巨大的弊病,内存占用过大。 本文给出另一种数据结构来解决上述问题---- Ternary Search Tree (三叉树) 二、数据结构定义 Trie 树中每个节点包含了 26 个指针,但有很大一部分的指针是 NULL 指针,因此浪费了大量的资源。 一种改进措施就是,以一棵树来代替上述的指针数组。...
分类:其他好文   时间:2014-05-01 17:49:30    阅读次数:326
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!