题目: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
【107-Binary Tree Level Order Traversal II(二叉树层序遍历II)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right,...
分类:
编程语言 时间:
2015-08-10 08:17:39
阅读次数:
169
【108-Convert Sorted Array to Binary Search Tree(排序数组转变为平衡二叉树)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
题目...
分类:
编程语言 时间:
2015-08-10 08:15:28
阅读次数:
136
【109-Convert Sorted List to Binary Search Tree(排序链表转换成二叉排序树)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a singly linked list where elements are sorted in ascending order, convert it to a height balanc...
分类:
编程语言 时间:
2015-08-10 08:14:28
阅读次数:
157
题目: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 onl...
分类:
其他好文 时间:
2015-08-10 08:13:31
阅读次数:
128
1、什么是二叉搜索树
二叉搜索树(Binary Search Tree)是一棵有序的二叉树,所以我们也可以称它为二叉排序树(不知道二叉树的童鞋,先看看二叉树:传送门)。具有以下性质的二叉树我们称之为二叉搜索树:若它的左子树不为空,那么左子树上的所有值均小于它的根节点;若它的右子树不为空,那么右子树上所有值均大于它的根节点。它的左子树和右子树分别也为二叉搜索树。
2、二叉搜索树的结...
分类:
其他好文 时间:
2015-08-10 07:07:01
阅读次数:
126
题目:Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the n...
分类:
其他好文 时间:
2015-08-10 07:04:35
阅读次数:
119