QestionGiven 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, (the...
分类:
其他好文 时间:
2015-08-11 07:18:19
阅读次数:
124
QuestionlinkImplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will ret...
分类:
其他好文 时间:
2015-08-11 07:10:50
阅读次数:
99
Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1.....
分类:
其他好文 时间:
2015-08-11 07:01:19
阅读次数:
122
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 / \ ...
分类:
其他好文 时间:
2015-08-11 07:00:30
阅读次数:
93
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 an...
分类:
其他好文 时间:
2015-08-11 00:12:30
阅读次数:
158
//LeetCode:https://leetcode.com/problems/flatten-binary-tree-to-linked-list/ //Flatten Binary Tree to Linked List 114 //前序遍历,last是链表最后一个节点,然后使用前序遍历,遍历...
分类:
其他好文 时间:
2015-08-10 23:39:02
阅读次数:
170
题目:Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing all 1’s and return its area.For example, given the following matrix:1 0 1 0 0
1 0 1 1 1
1 1 1 1 1
1 0 0 1 0Ret...
分类:
其他好文 时间:
2015-08-10 22:07:02
阅读次数:
128
当我们在字典中查找某个单的时候,一般我们会翻到一个大致的位置(假设吧,翻到中间位置),开始查找。如果翻到的正好有我们要的词,那运气好,查找结束。如果我们要找的词还在这个位置的前面,那我们对前面的这一半词典继续搜索,翻到某个位置(假设是四分之一的位置)等等。这个二分搜索的工作原理一样。相应的算法就叫做...
分类:
其他好文 时间:
2015-08-10 21:34:52
阅读次数:
93
File "ex_6.py", line 4, in (module) y = "Those who know %s and those who %s." (binary, do_not)? ??# used % TypeError:‘str‘ object is not callable? 少写一个% 转义字符 \\ ?\ \‘ \" \a \b \f \n \...
分类:
其他好文 时间:
2015-08-10 20:24:09
阅读次数:
131
BST 以下BST的定义来自于Wikipedia: Binary Search Tree, is a node-based binary tree data structure which has the following properties: The left subtree of a nod...
分类:
编程语言 时间:
2015-08-10 19:41:15
阅读次数:
130